Revise string literal usage

This commit covers src/gui folder.
PR #16757.
This commit is contained in:
Chocobo1 2022-03-29 10:41:17 +08:00 committed by GitHub
parent 746fe7ba09
commit 75c93d72be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 275 additions and 280 deletions

View file

@ -50,9 +50,9 @@ AboutDialog::AboutDialog(QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
// Title // Title
m_ui->labelName->setText(QString::fromLatin1("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8)); m_ui->labelName->setText(QStringLiteral("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("qbittorrent-tray")), this, 32)); m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"qbittorrent-tray"_qs), this, 32));
// About // About
const QString aboutText = const QString aboutText =

View file

@ -45,7 +45,7 @@
namespace namespace
{ {
QString makeLink(const QString &url, const QString &linkLabel) QString makeLink(const QStringView url, const QStringView linkLabel)
{ {
return u"<a href=\"%1\">%2</a>"_qs.arg(url, linkLabel); return u"<a href=\"%1\">%2</a>"_qs.arg(url, linkLabel);
} }
@ -359,8 +359,8 @@ void AdvancedSettings::updateInterfaceAddressCombo()
// Clear all items and reinsert them, default to all // Clear all items and reinsert them, default to all
m_comboBoxInterfaceAddress.clear(); m_comboBoxInterfaceAddress.clear();
m_comboBoxInterfaceAddress.addItem(tr("All addresses"), {}); m_comboBoxInterfaceAddress.addItem(tr("All addresses"), {});
m_comboBoxInterfaceAddress.addItem(tr("All IPv4 addresses"), QLatin1String("0.0.0.0")); m_comboBoxInterfaceAddress.addItem(tr("All IPv4 addresses"), u"0.0.0.0"_qs);
m_comboBoxInterfaceAddress.addItem(tr("All IPv6 addresses"), QLatin1String("::")); m_comboBoxInterfaceAddress.addItem(tr("All IPv6 addresses"), u"::"_qs);
const auto populateCombo = [this](const QHostAddress &addr) const auto populateCombo = [this](const QHostAddress &addr)
{ {
@ -400,19 +400,19 @@ void AdvancedSettings::loadAdvancedSettings()
// add section headers // add section headers
auto *labelQbtLink = new QLabel( auto *labelQbtLink = new QLabel(
makeLink(QLatin1String("https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced") makeLink(u"https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced"
, tr("Open documentation")) , tr("Open documentation"))
, this); , this);
labelQbtLink->setOpenExternalLinks(true); labelQbtLink->setOpenExternalLinks(true);
addRow(QBITTORRENT_HEADER, QString::fromLatin1("<b>%1</b>").arg(tr("qBittorrent Section")), labelQbtLink); addRow(QBITTORRENT_HEADER, u"<b>%1</b>"_qs.arg(tr("qBittorrent Section")), labelQbtLink);
static_cast<QLabel *>(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); static_cast<QLabel *>(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
auto *labelLibtorrentLink = new QLabel( auto *labelLibtorrentLink = new QLabel(
makeLink(QLatin1String("https://www.libtorrent.org/reference-Settings.html") makeLink(u"https://www.libtorrent.org/reference-Settings.html"
, tr("Open documentation")) , tr("Open documentation"))
, this); , this);
labelLibtorrentLink->setOpenExternalLinks(true); labelLibtorrentLink->setOpenExternalLinks(true);
addRow(LIBTORRENT_HEADER, QString::fromLatin1("<b>%1</b>").arg(tr("libtorrent Section")), labelLibtorrentLink); addRow(LIBTORRENT_HEADER, u"<b>%1</b>"_qs.arg(tr("libtorrent Section")), labelLibtorrentLink);
static_cast<QLabel *>(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); static_cast<QLabel *>(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
m_comboBoxResumeDataStorage.addItems({tr("Fastresume files"), tr("SQLite database (experimental)")}); m_comboBoxResumeDataStorage.addItems({tr("Fastresume files"), tr("SQLite database (experimental)")});
@ -443,7 +443,7 @@ void AdvancedSettings::loadAdvancedSettings()
} }
m_comboBoxOSMemoryPriority.setCurrentIndex(OSMemoryPriorityIndex); m_comboBoxOSMemoryPriority.setCurrentIndex(OSMemoryPriorityIndex);
addRow(OS_MEMORY_PRIORITY, (tr("Process memory priority (Windows >= 8 only)") addRow(OS_MEMORY_PRIORITY, (tr("Process memory priority (Windows >= 8 only)")
+ u' ' + makeLink(u"https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-memory_priority_information", u"(?)"))
, &m_comboBoxOSMemoryPriority); , &m_comboBoxOSMemoryPriority);
m_spinBoxMemoryWorkingSetLimit.setMinimum(1); m_spinBoxMemoryWorkingSetLimit.setMinimum(1);
@ -452,7 +452,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxMemoryWorkingSetLimit.setValue(static_cast<Application *>(QCoreApplication::instance())->memoryWorkingSetLimit()); m_spinBoxMemoryWorkingSetLimit.setValue(static_cast<Application *>(QCoreApplication::instance())->memoryWorkingSetLimit());
addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit") addRow(MEMORY_WORKING_SET_LIMIT, (tr("Physical memory (RAM) usage limit")
+ u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://wikipedia.org/wiki/Working_set", u"(?)"))
, &m_spinBoxMemoryWorkingSetLimit); , &m_spinBoxMemoryWorkingSetLimit);
#endif #endif
@ -460,7 +460,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxAsyncIOThreads.setMinimum(1); m_spinBoxAsyncIOThreads.setMinimum(1);
m_spinBoxAsyncIOThreads.setMaximum(1024); m_spinBoxAsyncIOThreads.setMaximum(1024);
m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads()); m_spinBoxAsyncIOThreads.setValue(session->asyncIOThreads());
addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#aio_threads"_qs, u"(?)"_qs)) addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#aio_threads", u"(?)"))
, &m_spinBoxAsyncIOThreads); , &m_spinBoxAsyncIOThreads);
#ifdef QBT_USES_LIBTORRENT2 #ifdef QBT_USES_LIBTORRENT2
@ -468,7 +468,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxHashingThreads.setMinimum(1); m_spinBoxHashingThreads.setMinimum(1);
m_spinBoxHashingThreads.setMaximum(1024); m_spinBoxHashingThreads.setMaximum(1024);
m_spinBoxHashingThreads.setValue(session->hashingThreads()); m_spinBoxHashingThreads.setValue(session->hashingThreads());
addRow(HASHING_THREADS, (tr("Hashing threads") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#hashing_threads"_qs, u"(?)"_qs)) addRow(HASHING_THREADS, (tr("Hashing threads") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#hashing_threads", u"(?)"))
, &m_spinBoxHashingThreads); , &m_spinBoxHashingThreads);
#endif #endif
@ -476,7 +476,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxFilePoolSize.setMinimum(1); m_spinBoxFilePoolSize.setMinimum(1);
m_spinBoxFilePoolSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxFilePoolSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxFilePoolSize.setValue(session->filePoolSize()); m_spinBoxFilePoolSize.setValue(session->filePoolSize());
addRow(FILE_POOL_SIZE, (tr("File pool size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#file_pool_size"_qs, u"(?)"_qs)) addRow(FILE_POOL_SIZE, (tr("File pool size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#file_pool_size", u"(?)"))
, &m_spinBoxFilePoolSize); , &m_spinBoxFilePoolSize);
// Checking Memory Usage // Checking Memory Usage
@ -490,7 +490,7 @@ void AdvancedSettings::loadAdvancedSettings()
#endif #endif
m_spinBoxCheckingMemUsage.setValue(session->checkingMemUsage()); m_spinBoxCheckingMemUsage.setValue(session->checkingMemUsage());
m_spinBoxCheckingMemUsage.setSuffix(tr(" MiB")); m_spinBoxCheckingMemUsage.setSuffix(tr(" MiB"));
addRow(CHECKING_MEM_USAGE, (tr("Outstanding memory when checking torrents") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#checking_mem_usage"_qs, u"(?)"_qs)) addRow(CHECKING_MEM_USAGE, (tr("Outstanding memory when checking torrents") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#checking_mem_usage", u"(?)"))
, &m_spinBoxCheckingMemUsage); , &m_spinBoxCheckingMemUsage);
#ifndef QBT_USES_LIBTORRENT2 #ifndef QBT_USES_LIBTORRENT2
// Disk write cache // Disk write cache
@ -506,14 +506,14 @@ void AdvancedSettings::loadAdvancedSettings()
updateCacheSpinSuffix(m_spinBoxCache.value()); updateCacheSpinSuffix(m_spinBoxCache.value());
connect(&m_spinBoxCache, qOverload<int>(&QSpinBox::valueChanged) connect(&m_spinBoxCache, qOverload<int>(&QSpinBox::valueChanged)
, this, &AdvancedSettings::updateCacheSpinSuffix); , this, &AdvancedSettings::updateCacheSpinSuffix);
addRow(DISK_CACHE, (tr("Disk cache") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#cache_size"_qs, u"(?)"_qs)) addRow(DISK_CACHE, (tr("Disk cache") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#cache_size", u"(?)"))
, &m_spinBoxCache); , &m_spinBoxCache);
// Disk cache expiry // Disk cache expiry
m_spinBoxCacheTTL.setMinimum(1); m_spinBoxCacheTTL.setMinimum(1);
m_spinBoxCacheTTL.setMaximum(std::numeric_limits<int>::max()); m_spinBoxCacheTTL.setMaximum(std::numeric_limits<int>::max());
m_spinBoxCacheTTL.setValue(session->diskCacheTTL()); m_spinBoxCacheTTL.setValue(session->diskCacheTTL());
m_spinBoxCacheTTL.setSuffix(tr(" s", " seconds")); m_spinBoxCacheTTL.setSuffix(tr(" s", " seconds"));
addRow(DISK_CACHE_TTL, (tr("Disk cache expiry interval") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#cache_expiry"_qs, u"(?)"_qs)) addRow(DISK_CACHE_TTL, (tr("Disk cache expiry interval") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#cache_expiry", u"(?)"))
, &m_spinBoxCacheTTL); , &m_spinBoxCacheTTL);
#endif #endif
// Disk queue size // Disk queue size
@ -521,55 +521,55 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxDiskQueueSize.setValue(session->diskQueueSize() / 1024); m_spinBoxDiskQueueSize.setValue(session->diskQueueSize() / 1024);
m_spinBoxDiskQueueSize.setSuffix(tr(" KiB")); m_spinBoxDiskQueueSize.setSuffix(tr(" KiB"));
addRow(DISK_QUEUE_SIZE, (tr("Disk queue size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes"_qs, u"(?)"_qs)) addRow(DISK_QUEUE_SIZE, (tr("Disk queue size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_queued_disk_bytes", u"(?)"))
, &m_spinBoxDiskQueueSize); , &m_spinBoxDiskQueueSize);
// Enable OS cache // Enable OS cache
m_checkBoxOsCache.setChecked(session->useOSCache()); m_checkBoxOsCache.setChecked(session->useOSCache());
addRow(OS_CACHE, (tr("Enable OS cache") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode"_qs, u"(?)"_qs)) addRow(OS_CACHE, (tr("Enable OS cache") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", u"(?)"))
, &m_checkBoxOsCache); , &m_checkBoxOsCache);
#ifndef QBT_USES_LIBTORRENT2 #ifndef QBT_USES_LIBTORRENT2
// Coalesce reads & writes // Coalesce reads & writes
m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled()); m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#coalesce_reads"_qs, u"(?)"_qs)) addRow(COALESCE_RW, (tr("Coalesce reads & writes") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#coalesce_reads", u"(?)"))
, &m_checkBoxCoalesceRW); , &m_checkBoxCoalesceRW);
#endif #endif
// Piece extent affinity // Piece extent affinity
m_checkBoxPieceExtentAffinity.setChecked(session->usePieceExtentAffinity()); m_checkBoxPieceExtentAffinity.setChecked(session->usePieceExtentAffinity());
addRow(PIECE_EXTENT_AFFINITY, (tr("Use piece extent affinity") + u' ' + makeLink(u"https://libtorrent.org/single-page-ref.html#piece_extent_affinity"_qs, u"(?)"_qs)), &m_checkBoxPieceExtentAffinity); addRow(PIECE_EXTENT_AFFINITY, (tr("Use piece extent affinity") + u' ' + makeLink(u"https://libtorrent.org/single-page-ref.html#piece_extent_affinity", u"(?)")), &m_checkBoxPieceExtentAffinity);
// Suggest mode // Suggest mode
m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled()); m_checkBoxSuggestMode.setChecked(session->isSuggestModeEnabled());
addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#suggest_mode"_qs, u"(?)"_qs)) addRow(SUGGEST_MODE, (tr("Send upload piece suggestions") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#suggest_mode", u"(?)"))
, &m_checkBoxSuggestMode); , &m_checkBoxSuggestMode);
// Send buffer watermark // Send buffer watermark
m_spinBoxSendBufferWatermark.setMinimum(1); m_spinBoxSendBufferWatermark.setMinimum(1);
m_spinBoxSendBufferWatermark.setMaximum(std::numeric_limits<int>::max()); m_spinBoxSendBufferWatermark.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSendBufferWatermark.setSuffix(tr(" KiB")); m_spinBoxSendBufferWatermark.setSuffix(tr(" KiB"));
m_spinBoxSendBufferWatermark.setValue(session->sendBufferWatermark()); m_spinBoxSendBufferWatermark.setValue(session->sendBufferWatermark());
addRow(SEND_BUF_WATERMARK, (tr("Send buffer watermark") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark"_qs, u"(?)"_qs)) addRow(SEND_BUF_WATERMARK, (tr("Send buffer watermark") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark", u"(?)"))
, &m_spinBoxSendBufferWatermark); , &m_spinBoxSendBufferWatermark);
m_spinBoxSendBufferLowWatermark.setMinimum(1); m_spinBoxSendBufferLowWatermark.setMinimum(1);
m_spinBoxSendBufferLowWatermark.setMaximum(std::numeric_limits<int>::max()); m_spinBoxSendBufferLowWatermark.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSendBufferLowWatermark.setSuffix(tr(" KiB")); m_spinBoxSendBufferLowWatermark.setSuffix(tr(" KiB"));
m_spinBoxSendBufferLowWatermark.setValue(session->sendBufferLowWatermark()); m_spinBoxSendBufferLowWatermark.setValue(session->sendBufferLowWatermark());
addRow(SEND_BUF_LOW_WATERMARK, (tr("Send buffer low watermark") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_low_watermark"_qs, u"(?)"_qs)) addRow(SEND_BUF_LOW_WATERMARK, (tr("Send buffer low watermark") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_low_watermark", u"(?)"))
, &m_spinBoxSendBufferLowWatermark); , &m_spinBoxSendBufferLowWatermark);
m_spinBoxSendBufferWatermarkFactor.setMinimum(1); m_spinBoxSendBufferWatermarkFactor.setMinimum(1);
m_spinBoxSendBufferWatermarkFactor.setMaximum(std::numeric_limits<int>::max()); m_spinBoxSendBufferWatermarkFactor.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSendBufferWatermarkFactor.setSuffix(u" %"_qs); m_spinBoxSendBufferWatermarkFactor.setSuffix(u" %"_qs);
m_spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor()); m_spinBoxSendBufferWatermarkFactor.setValue(session->sendBufferWatermarkFactor());
addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor"_qs, u"(?)"_qs)) addRow(SEND_BUF_WATERMARK_FACTOR, (tr("Send buffer watermark factor") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#send_buffer_watermark_factor", u"(?)"))
, &m_spinBoxSendBufferWatermarkFactor); , &m_spinBoxSendBufferWatermarkFactor);
// Outgoing connections per second // Outgoing connections per second
m_spinBoxConnectionSpeed.setMinimum(0); m_spinBoxConnectionSpeed.setMinimum(0);
m_spinBoxConnectionSpeed.setMaximum(std::numeric_limits<int>::max()); m_spinBoxConnectionSpeed.setMaximum(std::numeric_limits<int>::max());
m_spinBoxConnectionSpeed.setValue(session->connectionSpeed()); m_spinBoxConnectionSpeed.setValue(session->connectionSpeed());
addRow(CONNECTION_SPEED, (tr("Outgoing connections per second") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#connection_speed"_qs, u"(?)"_qs)) addRow(CONNECTION_SPEED, (tr("Outgoing connections per second") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#connection_speed", u"(?)"))
, &m_spinBoxConnectionSpeed); , &m_spinBoxConnectionSpeed);
// Socket listen backlog size // Socket listen backlog size
m_spinBoxSocketBacklogSize.setMinimum(1); m_spinBoxSocketBacklogSize.setMinimum(1);
m_spinBoxSocketBacklogSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxSocketBacklogSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxSocketBacklogSize.setValue(session->socketBacklogSize()); m_spinBoxSocketBacklogSize.setValue(session->socketBacklogSize());
addRow(SOCKET_BACKLOG_SIZE, (tr("Socket backlog size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#listen_queue_size"_qs, u"(?)"_qs)) addRow(SOCKET_BACKLOG_SIZE, (tr("Socket backlog size") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#listen_queue_size", u"(?)"))
, &m_spinBoxSocketBacklogSize); , &m_spinBoxSocketBacklogSize);
// Save resume data interval // Save resume data interval
m_spinBoxSaveResumeDataInterval.setMinimum(0); m_spinBoxSaveResumeDataInterval.setMinimum(0);
@ -584,57 +584,57 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxOutgoingPortsMin.setMaximum(65535); m_spinBoxOutgoingPortsMin.setMaximum(65535);
m_spinBoxOutgoingPortsMin.setValue(session->outgoingPortsMin()); m_spinBoxOutgoingPortsMin.setValue(session->outgoingPortsMin());
addRow(OUTGOING_PORT_MIN, (tr("Outgoing ports (Min) [0: Disabled]") addRow(OUTGOING_PORT_MIN, (tr("Outgoing ports (Min) [0: Disabled]")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u"(?)"))
, &m_spinBoxOutgoingPortsMin); , &m_spinBoxOutgoingPortsMin);
// Outgoing port Min // Outgoing port Min
m_spinBoxOutgoingPortsMax.setMinimum(0); m_spinBoxOutgoingPortsMax.setMinimum(0);
m_spinBoxOutgoingPortsMax.setMaximum(65535); m_spinBoxOutgoingPortsMax.setMaximum(65535);
m_spinBoxOutgoingPortsMax.setValue(session->outgoingPortsMax()); m_spinBoxOutgoingPortsMax.setValue(session->outgoingPortsMax());
addRow(OUTGOING_PORT_MAX, (tr("Outgoing ports (Max) [0: Disabled]") addRow(OUTGOING_PORT_MAX, (tr("Outgoing ports (Max) [0: Disabled]")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#outgoing_port", u"(?)"))
, &m_spinBoxOutgoingPortsMax); , &m_spinBoxOutgoingPortsMax);
// UPnP lease duration // UPnP lease duration
m_spinBoxUPnPLeaseDuration.setMinimum(0); m_spinBoxUPnPLeaseDuration.setMinimum(0);
m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits<int>::max()); m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits<int>::max());
m_spinBoxUPnPLeaseDuration.setValue(session->UPnPLeaseDuration()); m_spinBoxUPnPLeaseDuration.setValue(session->UPnPLeaseDuration());
m_spinBoxUPnPLeaseDuration.setSuffix(tr(" s", " seconds")); m_spinBoxUPnPLeaseDuration.setSuffix(tr(" s", " seconds"));
addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: Permanent lease]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration"_qs, u"(?)"_qs)) addRow(UPNP_LEASE_DURATION, (tr("UPnP lease duration [0: Permanent lease]") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#upnp_lease_duration", u"(?)"))
, &m_spinBoxUPnPLeaseDuration); , &m_spinBoxUPnPLeaseDuration);
// Type of service // Type of service
m_spinBoxPeerToS.setMinimum(0); m_spinBoxPeerToS.setMinimum(0);
m_spinBoxPeerToS.setMaximum(255); m_spinBoxPeerToS.setMaximum(255);
m_spinBoxPeerToS.setValue(session->peerToS()); m_spinBoxPeerToS.setValue(session->peerToS());
addRow(PEER_TOS, (tr("Type of service (ToS) for connections to peers") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_tos"_qs, u"(?)"_qs)) addRow(PEER_TOS, (tr("Type of service (ToS) for connections to peers") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_tos", u"(?)"))
, &m_spinBoxPeerToS); , &m_spinBoxPeerToS);
// uTP-TCP mixed mode // uTP-TCP mixed mode
m_comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")}); m_comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")});
m_comboBoxUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode())); m_comboBoxUtpMixedMode.setCurrentIndex(static_cast<int>(session->utpMixedMode()));
addRow(UTP_MIX_MODE, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP) addRow(UTP_MIX_MODE, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP)
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", u"(?)"))
, &m_comboBoxUtpMixedMode); , &m_comboBoxUtpMixedMode);
// Support internationalized domain name (IDN) // Support internationalized domain name (IDN)
m_checkBoxIDNSupport.setChecked(session->isIDNSupportEnabled()); m_checkBoxIDNSupport.setChecked(session->isIDNSupportEnabled());
addRow(IDN_SUPPORT, (tr("Support internationalized domain name (IDN)") addRow(IDN_SUPPORT, (tr("Support internationalized domain name (IDN)")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#allow_idna"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#allow_idna", u"(?)"))
, &m_checkBoxIDNSupport); , &m_checkBoxIDNSupport);
// multiple connections per IP // multiple connections per IP
m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled()); m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled());
addRow(MULTI_CONNECTIONS_PER_IP, (tr("Allow multiple connections from the same IP address") addRow(MULTI_CONNECTIONS_PER_IP, (tr("Allow multiple connections from the same IP address")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip", u"(?)"))
, &m_checkBoxMultiConnectionsPerIp); , &m_checkBoxMultiConnectionsPerIp);
// Validate HTTPS tracker certificate // Validate HTTPS tracker certificate
m_checkBoxValidateHTTPSTrackerCertificate.setChecked(session->validateHTTPSTrackerCertificate()); m_checkBoxValidateHTTPSTrackerCertificate.setChecked(session->validateHTTPSTrackerCertificate());
addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE, (tr("Validate HTTPS tracker certificates") addRow(VALIDATE_HTTPS_TRACKER_CERTIFICATE, (tr("Validate HTTPS tracker certificates")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#validate_https_trackers"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#validate_https_trackers", u"(?)"))
, &m_checkBoxValidateHTTPSTrackerCertificate); , &m_checkBoxValidateHTTPSTrackerCertificate);
// SSRF mitigation // SSRF mitigation
m_checkBoxSSRFMitigation.setChecked(session->isSSRFMitigationEnabled()); m_checkBoxSSRFMitigation.setChecked(session->isSSRFMitigationEnabled());
addRow(SSRF_MITIGATION, (tr("Server-side request forgery (SSRF) mitigation") addRow(SSRF_MITIGATION, (tr("Server-side request forgery (SSRF) mitigation")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#ssrf_mitigation", u"(?)"))
, &m_checkBoxSSRFMitigation); , &m_checkBoxSSRFMitigation);
// Disallow connection to peers on privileged ports // Disallow connection to peers on privileged ports
m_checkBoxBlockPeersOnPrivilegedPorts.setChecked(session->blockPeersOnPrivilegedPorts()); m_checkBoxBlockPeersOnPrivilegedPorts.setChecked(session->blockPeersOnPrivilegedPorts());
addRow(BLOCK_PEERS_ON_PRIVILEGED_PORTS, (tr("Disallow connection to peers on privileged ports") + u' ' + makeLink(u"https://libtorrent.org/single-page-ref.html#no_connect_privileged_ports"_qs, u"(?)"_qs)), &m_checkBoxBlockPeersOnPrivilegedPorts); addRow(BLOCK_PEERS_ON_PRIVILEGED_PORTS, (tr("Disallow connection to peers on privileged ports") + u' ' + makeLink(u"https://libtorrent.org/single-page-ref.html#no_connect_privileged_ports", u"(?)")), &m_checkBoxBlockPeersOnPrivilegedPorts);
// Recheck completed torrents // Recheck completed torrents
m_checkBoxRecheckCompleted.setChecked(pref->recheckTorrentsOnCompletion()); m_checkBoxRecheckCompleted.setChecked(pref->recheckTorrentsOnCompletion());
addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted); addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted);
@ -680,17 +680,17 @@ void AdvancedSettings::loadAdvancedSettings()
// Announce IP // Announce IP
m_lineEditAnnounceIP.setText(session->announceIP()); m_lineEditAnnounceIP.setText(session->announceIP());
addRow(ANNOUNCE_IP, (tr("IP address reported to trackers (requires restart)") addRow(ANNOUNCE_IP, (tr("IP address reported to trackers (requires restart)")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_ip"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_ip", u"(?)"))
, &m_lineEditAnnounceIP); , &m_lineEditAnnounceIP);
// Max concurrent HTTP announces // Max concurrent HTTP announces
m_spinBoxMaxConcurrentHTTPAnnounces.setMaximum(std::numeric_limits<int>::max()); m_spinBoxMaxConcurrentHTTPAnnounces.setMaximum(std::numeric_limits<int>::max());
m_spinBoxMaxConcurrentHTTPAnnounces.setValue(session->maxConcurrentHTTPAnnounces()); m_spinBoxMaxConcurrentHTTPAnnounces.setValue(session->maxConcurrentHTTPAnnounces());
addRow(MAX_CONCURRENT_HTTP_ANNOUNCES, (tr("Max concurrent HTTP announces") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces"_qs, u"(?)"_qs)) addRow(MAX_CONCURRENT_HTTP_ANNOUNCES, (tr("Max concurrent HTTP announces") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_concurrent_http_announces", u"(?)"))
, &m_spinBoxMaxConcurrentHTTPAnnounces); , &m_spinBoxMaxConcurrentHTTPAnnounces);
// Stop tracker timeout // Stop tracker timeout
m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout()); m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout());
m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds")); m_spinBoxStopTrackerTimeout.setSuffix(tr(" s", " seconds"));
addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout"_qs, u"(?)"_qs)) addRow(STOP_TRACKER_TIMEOUT, (tr("Stop tracker timeout") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#stop_tracker_timeout", u"(?)"))
, &m_spinBoxStopTrackerTimeout); , &m_spinBoxStopTrackerTimeout);
// Program notifications // Program notifications
@ -738,12 +738,12 @@ void AdvancedSettings::loadAdvancedSettings()
// Choking algorithm // Choking algorithm
m_comboBoxChokingAlgorithm.addItems({tr("Fixed slots"), tr("Upload rate based")}); m_comboBoxChokingAlgorithm.addItems({tr("Fixed slots"), tr("Upload rate based")});
m_comboBoxChokingAlgorithm.setCurrentIndex(static_cast<int>(session->chokingAlgorithm())); m_comboBoxChokingAlgorithm.setCurrentIndex(static_cast<int>(session->chokingAlgorithm()));
addRow(CHOKING_ALGORITHM, (tr("Upload slots behavior") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#choking_algorithm"_qs, u"(?)"_qs)) addRow(CHOKING_ALGORITHM, (tr("Upload slots behavior") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#choking_algorithm", u"(?)"))
, &m_comboBoxChokingAlgorithm); , &m_comboBoxChokingAlgorithm);
// Seed choking algorithm // Seed choking algorithm
m_comboBoxSeedChokingAlgorithm.addItems({tr("Round-robin"), tr("Fastest upload"), tr("Anti-leech")}); m_comboBoxSeedChokingAlgorithm.addItems({tr("Round-robin"), tr("Fastest upload"), tr("Anti-leech")});
m_comboBoxSeedChokingAlgorithm.setCurrentIndex(static_cast<int>(session->seedChokingAlgorithm())); m_comboBoxSeedChokingAlgorithm.setCurrentIndex(static_cast<int>(session->seedChokingAlgorithm()));
addRow(SEED_CHOKING_ALGORITHM, (tr("Upload choking algorithm") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm"_qs, u"(?)"_qs)) addRow(SEED_CHOKING_ALGORITHM, (tr("Upload choking algorithm") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#seed_choking_algorithm", u"(?)"))
, &m_comboBoxSeedChokingAlgorithm); , &m_comboBoxSeedChokingAlgorithm);
// Torrent recheck confirmation // Torrent recheck confirmation
@ -757,38 +757,38 @@ void AdvancedSettings::loadAdvancedSettings()
// Announce to all trackers in a tier // Announce to all trackers in a tier
m_checkBoxAnnounceAllTrackers.setChecked(session->announceToAllTrackers()); m_checkBoxAnnounceAllTrackers.setChecked(session->announceToAllTrackers());
addRow(ANNOUNCE_ALL_TRACKERS, (tr("Always announce to all trackers in a tier") addRow(ANNOUNCE_ALL_TRACKERS, (tr("Always announce to all trackers in a tier")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_to_all_trackers", u"(?)"))
, &m_checkBoxAnnounceAllTrackers); , &m_checkBoxAnnounceAllTrackers);
// Announce to all tiers // Announce to all tiers
m_checkBoxAnnounceAllTiers.setChecked(session->announceToAllTiers()); m_checkBoxAnnounceAllTiers.setChecked(session->announceToAllTiers());
addRow(ANNOUNCE_ALL_TIERS, (tr("Always announce to all tiers") addRow(ANNOUNCE_ALL_TIERS, (tr("Always announce to all tiers")
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers"_qs, u"(?)"_qs)) + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_to_all_tiers", u"(?)"))
, &m_checkBoxAnnounceAllTiers); , &m_checkBoxAnnounceAllTiers);
m_spinBoxPeerTurnover.setMinimum(0); m_spinBoxPeerTurnover.setMinimum(0);
m_spinBoxPeerTurnover.setMaximum(100); m_spinBoxPeerTurnover.setMaximum(100);
m_spinBoxPeerTurnover.setValue(session->peerTurnover()); m_spinBoxPeerTurnover.setValue(session->peerTurnover());
m_spinBoxPeerTurnover.setSuffix(u" %"_qs); m_spinBoxPeerTurnover.setSuffix(u" %"_qs);
addRow(PEER_TURNOVER, (tr("Peer turnover disconnect percentage") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover"_qs, u"(?)"_qs)) addRow(PEER_TURNOVER, (tr("Peer turnover disconnect percentage") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u"(?)"))
, &m_spinBoxPeerTurnover); , &m_spinBoxPeerTurnover);
m_spinBoxPeerTurnoverCutoff.setMinimum(0); m_spinBoxPeerTurnoverCutoff.setMinimum(0);
m_spinBoxPeerTurnoverCutoff.setMaximum(100); m_spinBoxPeerTurnoverCutoff.setMaximum(100);
m_spinBoxPeerTurnoverCutoff.setSuffix(u" %"_qs); m_spinBoxPeerTurnoverCutoff.setSuffix(u" %"_qs);
m_spinBoxPeerTurnoverCutoff.setValue(session->peerTurnoverCutoff()); m_spinBoxPeerTurnoverCutoff.setValue(session->peerTurnoverCutoff());
addRow(PEER_TURNOVER_CUTOFF, (tr("Peer turnover threshold percentage") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover"_qs, u"(?)"_qs)) addRow(PEER_TURNOVER_CUTOFF, (tr("Peer turnover threshold percentage") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u"(?)"))
, &m_spinBoxPeerTurnoverCutoff); , &m_spinBoxPeerTurnoverCutoff);
m_spinBoxPeerTurnoverInterval.setMinimum(30); m_spinBoxPeerTurnoverInterval.setMinimum(30);
m_spinBoxPeerTurnoverInterval.setMaximum(3600); m_spinBoxPeerTurnoverInterval.setMaximum(3600);
m_spinBoxPeerTurnoverInterval.setSuffix(tr(" s", " seconds")); m_spinBoxPeerTurnoverInterval.setSuffix(tr(" s", " seconds"));
m_spinBoxPeerTurnoverInterval.setValue(session->peerTurnoverInterval()); m_spinBoxPeerTurnoverInterval.setValue(session->peerTurnoverInterval());
addRow(PEER_TURNOVER_INTERVAL, (tr("Peer turnover disconnect interval") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover"_qs, u"(?)"_qs)) addRow(PEER_TURNOVER_INTERVAL, (tr("Peer turnover disconnect interval") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#peer_turnover", u"(?)"))
, &m_spinBoxPeerTurnoverInterval); , &m_spinBoxPeerTurnoverInterval);
// Maximum outstanding requests to a single peer // Maximum outstanding requests to a single peer
m_spinBoxRequestQueueSize.setMinimum(1); m_spinBoxRequestQueueSize.setMinimum(1);
m_spinBoxRequestQueueSize.setMaximum(std::numeric_limits<int>::max()); m_spinBoxRequestQueueSize.setMaximum(std::numeric_limits<int>::max());
m_spinBoxRequestQueueSize.setValue(session->requestQueueSize()); m_spinBoxRequestQueueSize.setValue(session->requestQueueSize());
addRow(REQUEST_QUEUE_SIZE, (tr("Maximum outstanding requests to a single peer") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_out_request_queue"_qs, u"(?)"_qs)) addRow(REQUEST_QUEUE_SIZE, (tr("Maximum outstanding requests to a single peer") + u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#max_out_request_queue", u"(?)"))
, &m_spinBoxRequestQueueSize); , &m_spinBoxRequestQueueSize);
} }

View file

@ -76,7 +76,7 @@ public:
if (!m_parent || m_parent->name().isEmpty()) if (!m_parent || m_parent->name().isEmpty())
return m_name; return m_name;
return QString::fromLatin1("%1/%2").arg(m_parent->fullName(), m_name); return u"%1/%2"_qs.arg(m_parent->fullName(), m_name);
} }
CategoryModelItem *parent() const CategoryModelItem *parent() const
@ -165,7 +165,7 @@ namespace
{ {
QString shortName(const QString &fullName) QString shortName(const QString &fullName)
{ {
int pos = fullName.lastIndexOf(QLatin1Char('/')); int pos = fullName.lastIndexOf(u'/');
if (pos >= 0) if (pos >= 0)
return fullName.mid(pos + 1); return fullName.mid(pos + 1);
return fullName; return fullName;

View file

@ -88,8 +88,8 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent)
uniqueURLs << str; uniqueURLs << str;
} }
const QString text = uniqueURLs.values().join(QLatin1Char('\n')) const QString text = uniqueURLs.values().join(u'\n')
+ (!uniqueURLs.isEmpty() ? QLatin1String("\n") : QLatin1String("")); + (!uniqueURLs.isEmpty() ? u"\n" : u"");
m_ui->textUrls->setText(text); m_ui->textUrls->setText(text);
m_ui->textUrls->moveCursor(QTextCursor::End); m_ui->textUrls->moveCursor(QTextCursor::End);

View file

@ -98,10 +98,10 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate(
{ {
m_browseAction->setIconText(browseButtonBriefText.tr()); m_browseAction->setIconText(browseButtonBriefText.tr());
m_browseAction->setText(browseButtonFullText.tr()); m_browseAction->setText(browseButtonFullText.tr());
m_browseAction->setToolTip(browseButtonFullText.tr().remove(QLatin1Char('&'))); m_browseAction->setToolTip(browseButtonFullText.tr().remove(u'&'));
m_browseAction->setShortcut(Qt::CTRL + Qt::Key_B); m_browseAction->setShortcut(Qt::CTRL + Qt::Key_B);
m_browseBtn->setDefaultAction(m_browseAction); m_browseBtn->setDefaultAction(m_browseAction);
m_fileNameFilter = tr("Any file") + QLatin1String(" (*)"); m_fileNameFilter = tr("Any file") + u" (*)";
m_editor->setBrowseAction(m_browseAction); m_editor->setBrowseAction(m_browseAction);
m_validator->setStrictMode(false); m_validator->setStrictMode(false);
m_editor->setValidator(m_validator); m_editor->setValidator(m_validator);
@ -233,18 +233,18 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val)
// QFileSystemModel applies name filters to directories too. // QFileSystemModel applies name filters to directories too.
// To use the filters we have to subclass QFileSystemModel and skip directories while filtering // To use the filters we have to subclass QFileSystemModel and skip directories while filtering
// extract file masks // extract file masks
const int openBracePos = val.indexOf(QLatin1Char('('), 0); const int openBracePos = val.indexOf(u'(');
const int closeBracePos = val.indexOf(QLatin1Char(')'), openBracePos + 1); const int closeBracePos = val.indexOf(u')', (openBracePos + 1));
if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2)) if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2))
{ {
QString filterString = val.mid(openBracePos + 1, closeBracePos - openBracePos - 1); QString filterString = val.mid(openBracePos + 1, closeBracePos - openBracePos - 1);
if (filterString == QLatin1String("*")) if (filterString == u"*")
{ // no filters { // no filters
d->m_editor->setFilenameFilters({}); d->m_editor->setFilenameFilters({});
} }
else else
{ {
QStringList filters = filterString.split(QLatin1Char(' '), Qt::SkipEmptyParts); QStringList filters = filterString.split(u' ', Qt::SkipEmptyParts);
d->m_editor->setFilenameFilters(filters); d->m_editor->setFilenameFilters(filters);
} }
} }

View file

@ -28,7 +28,7 @@ LineEdit::LineEdit(QWidget *parent)
m_searchButton->setStyleSheet(u"QToolButton {border: none; padding: 2px;}"_qs); m_searchButton->setStyleSheet(u"QToolButton {border: none; padding: 2px;}"_qs);
// padding between text and widget borders // padding between text and widget borders
setStyleSheet(QString::fromLatin1("QLineEdit {padding-left: %1px;}").arg(m_searchButton->sizeHint().width())); setStyleSheet(u"QLineEdit {padding-left: %1px;}"_qs.arg(m_searchButton->sizeHint().width()));
setClearButtonEnabled(true); setClearButtonEnabled(true);

View file

@ -37,12 +37,13 @@
#include <QStyle> #include <QStyle>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include "base/global.h"
#include "gui/uithememanager.h" #include "gui/uithememanager.h"
#include "logmodel.h" #include "logmodel.h"
namespace namespace
{ {
const QString SEPARATOR = QStringLiteral(" - "); const QString SEPARATOR = u" - "_qs;
int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text) int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text)
{ {
@ -51,7 +52,7 @@ namespace
QString logText(const QModelIndex &index) QString logText(const QModelIndex &index)
{ {
return QString::fromLatin1("%1%2%3").arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR return u"%1%2%3"_qs.arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR
, index.data(BaseLogModel::MessageRole).toString()); , index.data(BaseLogModel::MessageRole).toString());
} }

View file

@ -73,7 +73,7 @@ QVariant BaseLogModel::Message::type() const
BaseLogModel::BaseLogModel(QObject *parent) BaseLogModel::BaseLogModel(QObject *parent)
: QAbstractListModel(parent) : QAbstractListModel(parent)
, m_messages(MAX_VISIBLE_MESSAGES) , m_messages(MAX_VISIBLE_MESSAGES)
, m_timeForeground(UIThemeManager::instance()->getColor(QLatin1String("Log.TimeStamp"), Qt::darkGray)) , m_timeForeground(UIThemeManager::instance()->getColor(u"Log.TimeStamp"_qs, Qt::darkGray))
{ {
} }
@ -142,10 +142,10 @@ LogMessageModel::LogMessageModel(QObject *parent)
: BaseLogModel(parent) : BaseLogModel(parent)
, m_foregroundForMessageTypes , m_foregroundForMessageTypes
{ {
{Log::NORMAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Normal"), QApplication::palette().color(QPalette::WindowText))}, {Log::NORMAL, UIThemeManager::instance()->getColor(u"Log.Normal"_qs, QApplication::palette().color(QPalette::WindowText))},
{Log::INFO, UIThemeManager::instance()->getColor(QLatin1String("Log.Info"), Qt::blue)}, {Log::INFO, UIThemeManager::instance()->getColor(u"Log.Info"_qs, Qt::blue)},
{Log::WARNING, UIThemeManager::instance()->getColor(QLatin1String("Log.Warning"), QColor {255, 165, 0})}, // orange {Log::WARNING, UIThemeManager::instance()->getColor(u"Log.Warning"_qs, QColor {255, 165, 0})}, // orange
{Log::CRITICAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Critical"), Qt::red)} {Log::CRITICAL, UIThemeManager::instance()->getColor(u"Log.Critical"_qs, Qt::red)}
} }
{ {
for (const Log::Msg &msg : asConst(Logger::instance()->getMessages())) for (const Log::Msg &msg : asConst(Logger::instance()->getMessages()))
@ -164,7 +164,7 @@ void LogMessageModel::handleNewMessage(const Log::Msg &message)
LogPeerModel::LogPeerModel(QObject *parent) LogPeerModel::LogPeerModel(QObject *parent)
: BaseLogModel(parent) : BaseLogModel(parent)
, m_bannedPeerForeground(UIThemeManager::instance()->getColor(QLatin1String("Log.BannedPeer"), Qt::red)) , m_bannedPeerForeground(UIThemeManager::instance()->getColor(u"Log.BannedPeer"_qs, Qt::red))
{ {
for (const Log::Peer &peer : asConst(Logger::instance()->getPeers())) for (const Log::Peer &peer : asConst(Logger::instance()->getPeers()))
handleNewMessage(peer); handleNewMessage(peer);

View file

@ -115,9 +115,9 @@ namespace
bool isTorrentLink(const QString &str) bool isTorrentLink(const QString &str)
{ {
return str.startsWith(QLatin1String("magnet:"), Qt::CaseInsensitive) return str.startsWith(u"magnet:", Qt::CaseInsensitive)
|| str.endsWith(TORRENT_FILE_EXTENSION, Qt::CaseInsensitive) || str.endsWith(TORRENT_FILE_EXTENSION, Qt::CaseInsensitive)
|| (!str.startsWith(QLatin1String("file:"), Qt::CaseInsensitive) || (!str.startsWith(u"file:", Qt::CaseInsensitive)
&& Net::DownloadManager::hasSupportedScheme(str)); && Net::DownloadManager::hasSupportedScheme(str));
} }
} }
@ -1643,7 +1643,7 @@ void MainWindow::reloadSessionStats()
#else #else
if (m_systrayIcon) if (m_systrayIcon)
{ {
const auto toolTip = QString::fromLatin1("%1\n%2").arg( const auto toolTip = u"%1\n%2"_qs.arg(
tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true)) tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
, tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); , tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true)));
m_systrayIcon->setToolTip(toolTip); // tray icon m_systrayIcon->setToolTip(toolTip); // tray icon
@ -1674,8 +1674,8 @@ void MainWindow::showNotificationBalloon(const QString &title, const QString &ms
return; return;
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB)
OrgFreedesktopNotificationsInterface notifications(QLatin1String("org.freedesktop.Notifications") OrgFreedesktopNotificationsInterface notifications(u"org.freedesktop.Notifications"_qs
, QLatin1String("/org/freedesktop/Notifications") , u"/org/freedesktop/Notifications"_qs
, QDBusConnection::sessionBus()); , QDBusConnection::sessionBus());
// Testing for 'notifications.isValid()' isn't helpful here. // Testing for 'notifications.isValid()' isn't helpful here.
@ -1687,9 +1687,9 @@ void MainWindow::showNotificationBalloon(const QString &title, const QString &ms
// some inactivity shuts it down. Other DEs, like GNOME, choose // some inactivity shuts it down. Other DEs, like GNOME, choose
// to start their daemons at the session startup and have it sit // to start their daemons at the session startup and have it sit
// idling for the whole session. // idling for the whole session.
const QVariantMap hints {{QLatin1String("desktop-entry"), QLatin1String("org.qbittorrent.qBittorrent")}}; const QVariantMap hints {{u"desktop-entry"_qs, u"org.qbittorrent.qBittorrent"_qs}};
QDBusPendingReply<uint> reply = notifications.Notify(QLatin1String("qBittorrent"), 0 QDBusPendingReply<uint> reply = notifications.Notify(u"qBittorrent"_qs, 0
, QLatin1String("qbittorrent"), title, msg, {}, hints, getNotificationTimeout()); , u"qbittorrent"_qs, title, msg, {}, hints, getNotificationTimeout());
reply.waitForFinished(); reply.waitForFinished();
if (!reply.isError()) if (!reply.isError())
@ -1948,7 +1948,7 @@ void MainWindow::handleUpdateCheckFinished(ProgramUpdater *updater, const bool i
{ {
const QString msg {tr("A new version is available.") + u"<br/>" const QString msg {tr("A new version is available.") + u"<br/>"
+ tr("Do you want to download %1?").arg(newVersion) + u"<br/><br/>" + tr("Do you want to download %1?").arg(newVersion) + u"<br/><br/>"
+ QString::fromLatin1("<a href=\"https://www.qbittorrent.org/news.php\">%1</a>").arg(tr("Open changelog..."))}; + u"<a href=\"https://www.qbittorrent.org/news.php\">%1</a>"_qs.arg(tr("Open changelog..."))};
auto *msgBox = new QMessageBox {QMessageBox::Question, tr("qBittorrent Update Available"), msg auto *msgBox = new QMessageBox {QMessageBox::Question, tr("qBittorrent Update Available"), msg
, (QMessageBox::Yes | QMessageBox::No), this}; , (QMessageBox::Yes | QMessageBox::No), this};
msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setAttribute(Qt::WA_DeleteOnClose);
@ -1968,7 +1968,7 @@ void MainWindow::handleUpdateCheckFinished(ProgramUpdater *updater, const bool i
{ {
if (invokedByUser) if (invokedByUser)
{ {
auto *msgBox = new QMessageBox {QMessageBox::Information, QLatin1String("qBittorrent") auto *msgBox = new QMessageBox {QMessageBox::Information, u"qBittorrent"_qs
, tr("No updates available.\nYou are already using the latest version.") , tr("No updates available.\nYou are already using the latest version.")
, QMessageBox::Ok, this}; , QMessageBox::Ok, this};
msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setAttribute(Qt::WA_DeleteOnClose);

View file

@ -224,18 +224,18 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16)); m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16));
m_ui->deleteTorrentWarningIcon->hide(); m_ui->deleteTorrentWarningIcon->hide();
m_ui->deleteTorrentWarningLabel->hide(); m_ui->deleteTorrentWarningLabel->hide();
m_ui->deleteTorrentWarningLabel->setToolTip(QLatin1String("<html><body><p>") + m_ui->deleteTorrentWarningLabel->setToolTip(u"<html><body><p>" +
tr("By enabling these options, you can <strong>irrevocably lose</strong> your .torrent files!") + tr("By enabling these options, you can <strong>irrevocably lose</strong> your .torrent files!") +
QLatin1String("</p><p>") + u"</p><p>" +
tr("When these options are enabled, qBittorrent will <strong>delete</strong> .torrent files " tr("When these options are enabled, qBittorrent will <strong>delete</strong> .torrent files "
"after they were successfully (the first option) or not (the second option) added to its " "after they were successfully (the first option) or not (the second option) added to its "
"download queue. This will be applied <strong>not only</strong> to the files opened via " "download queue. This will be applied <strong>not only</strong> to the files opened via "
"&ldquo;Add torrent&rdquo; menu action but to those opened via <strong>file type association</strong> as well") + "&ldquo;Add torrent&rdquo; menu action but to those opened via <strong>file type association</strong> as well") +
QLatin1String("</p><p>") + u"</p><p>" +
tr("If you enable the second option (&ldquo;Also when addition is cancelled&rdquo;) the " tr("If you enable the second option (&ldquo;Also when addition is cancelled&rdquo;) the "
".torrent file <strong>will be deleted</strong> even if you press &ldquo;<strong>Cancel</strong>&rdquo; in " ".torrent file <strong>will be deleted</strong> even if you press &ldquo;<strong>Cancel</strong>&rdquo; in "
"the &ldquo;Add torrent&rdquo; dialog") + "the &ldquo;Add torrent&rdquo; dialog") +
QLatin1String("</p></body></html>")); u"</p></body></html>");
m_ui->hsplitter->setCollapsible(0, false); m_ui->hsplitter->setCollapsible(0, false);
m_ui->hsplitter->setCollapsible(1, false); m_ui->hsplitter->setCollapsible(1, false);
@ -472,9 +472,9 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton); connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton); connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
const QString slowTorrentsExplanation = QLatin1String("<html><body><p>") const QString slowTorrentsExplanation = u"<html><body><p>"
+ tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds") + tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds")
+ QLatin1String("</p></body></html>"); + u"</p></body></html>";
m_ui->labelDownloadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); m_ui->labelDownloadRateForSlowTorrents->setToolTip(slowTorrentsExplanation);
m_ui->labelUploadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); m_ui->labelUploadRateForSlowTorrents->setToolTip(slowTorrentsExplanation);
m_ui->labelSlowTorrentInactivityTimer->setToolTip(slowTorrentsExplanation); m_ui->labelSlowTorrentInactivityTimer->setToolTip(slowTorrentsExplanation);
@ -482,10 +482,10 @@ OptionsDialog::OptionsDialog(QWidget *parent)
#ifndef DISABLE_WEBUI #ifndef DISABLE_WEBUI
// Web UI tab // Web UI tab
m_ui->textWebUIHttpsCert->setMode(FileSystemPathEdit::Mode::FileOpen); m_ui->textWebUIHttpsCert->setMode(FileSystemPathEdit::Mode::FileOpen);
m_ui->textWebUIHttpsCert->setFileNameFilter(tr("Certificate") + QLatin1String(" (*.cer *.crt *.pem)")); m_ui->textWebUIHttpsCert->setFileNameFilter(tr("Certificate") + u" (*.cer *.crt *.pem)");
m_ui->textWebUIHttpsCert->setDialogCaption(tr("Select certificate")); m_ui->textWebUIHttpsCert->setDialogCaption(tr("Select certificate"));
m_ui->textWebUIHttpsKey->setMode(FileSystemPathEdit::Mode::FileOpen); m_ui->textWebUIHttpsKey->setMode(FileSystemPathEdit::Mode::FileOpen);
m_ui->textWebUIHttpsKey->setFileNameFilter(tr("Private key") + QLatin1String(" (*.key *.pem)")); m_ui->textWebUIHttpsKey->setFileNameFilter(tr("Private key") + u" (*.key *.pem)");
m_ui->textWebUIHttpsKey->setDialogCaption(tr("Select private key")); m_ui->textWebUIHttpsKey->setDialogCaption(tr("Select private key"));
connect(m_ui->textServerDomains, &QLineEdit::textChanged, this, &ThisType::enableApplyButton); connect(m_ui->textServerDomains, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
@ -558,7 +558,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
m_ui->textFilterPath->setDialogCaption(tr("Choose an IP filter file")); m_ui->textFilterPath->setDialogCaption(tr("Choose an IP filter file"));
m_ui->textFilterPath->setFileNameFilter(tr("All supported filters") m_ui->textFilterPath->setFileNameFilter(tr("All supported filters")
+ QLatin1String(" (*.dat *.p2p *.p2b);;.dat (*.dat);;.p2p (*.p2p);;.p2b (*.p2b)")); + u" (*.dat *.p2p *.p2b);;.dat (*.dat);;.p2p (*.p2p);;.p2b (*.p2b)");
m_ui->textSavePath->setDialogCaption(tr("Choose a save directory")); m_ui->textSavePath->setDialogCaption(tr("Choose a save directory"));
m_ui->textSavePath->setMode(FileSystemPathEdit::Mode::DirectorySave); m_ui->textSavePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
@ -661,7 +661,7 @@ void OptionsDialog::saveOptions()
if (pref->getLocale() != locale) if (pref->getLocale() != locale)
{ {
auto *translator = new QTranslator; auto *translator = new QTranslator;
if (translator->load(QLatin1String(":/lang/qbittorrent_") + locale)) if (translator->load(u":/lang/qbittorrent_"_qs + locale))
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale)); qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
else else
qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale)); qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale));
@ -1765,7 +1765,7 @@ QString OptionsDialog::webUiPassword() const
void OptionsDialog::webUIHttpsCertChanged(const Path &path, const ShowError showError) void OptionsDialog::webUIHttpsCertChanged(const Path &path, const ShowError showError)
{ {
m_ui->textWebUIHttpsCert->setSelectedPath(path); m_ui->textWebUIHttpsCert->setSelectedPath(path);
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("security-low")), this, 24)); m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"security-low"_qs), this, 24));
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -1785,13 +1785,13 @@ void OptionsDialog::webUIHttpsCertChanged(const Path &path, const ShowError show
return; return;
} }
m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("security-high")), this, 24)); m_ui->lblSslCertStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"security-high"_qs), this, 24));
} }
void OptionsDialog::webUIHttpsKeyChanged(const Path &path, const ShowError showError) void OptionsDialog::webUIHttpsKeyChanged(const Path &path, const ShowError showError)
{ {
m_ui->textWebUIHttpsKey->setSelectedPath(path); m_ui->textWebUIHttpsKey->setSelectedPath(path);
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("security-low")), this, 24)); m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"security-low"_qs), this, 24));
if (path.isEmpty()) if (path.isEmpty())
return; return;
@ -1811,7 +1811,7 @@ void OptionsDialog::webUIHttpsKeyChanged(const Path &path, const ShowError showE
return; return;
} }
m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("security-high")), this, 24)); m_ui->lblSslKeyStatus->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"security-high"_qs), this, 24));
} }
void OptionsDialog::showConnectionTab() void OptionsDialog::showConnectionTab()

View file

@ -57,7 +57,7 @@ void PreviewListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
{ {
const qreal progress = (index.data().toReal() * 100); const qreal progress = (index.data().toReal() * 100);
const QString text = (progress >= 100) const QString text = (progress >= 100)
? QString::fromLatin1("100%") ? u"100%"_qs
: (Utils::String::fromDouble(progress, 1) + u'%'); : (Utils::String::fromDouble(progress, 1) + u'%');
m_progressBarPainter.paint(painter, option, text, static_cast<int>(progress)); m_progressBarPainter.paint(painter, option, text, static_cast<int>(progress));

View file

@ -60,8 +60,8 @@ namespace
const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD}; const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD};
if (newVersion == currentVersion) if (newVersion == currentVersion)
{ {
const bool isDevVersion = QString::fromLatin1(QBT_VERSION_STATUS).contains( const bool isDevVersion = QStringLiteral(QBT_VERSION_STATUS).contains(
QRegularExpression(QLatin1String("(alpha|beta|rc)"))); QRegularExpression(u"(alpha|beta|rc)"_qs));
if (isDevVersion) if (isDevVersion)
return true; return true;
} }
@ -76,7 +76,7 @@ namespace
void ProgramUpdater::checkForUpdates() const void ProgramUpdater::checkForUpdates() const
{ {
const auto RSS_URL = QString::fromLatin1("https://www.fosshub.com/feed/5b8793a7f9ee5a5c3e97a3b2.xml"); const auto RSS_URL = u"https://www.fosshub.com/feed/5b8793a7f9ee5a5c3e97a3b2.xml"_qs;
// Don't change this User-Agent. In case our updater goes haywire, // Don't change this User-Agent. In case our updater goes haywire,
// the filehost can identify it and contact us. // the filehost can identify it and contact us.
Net::DownloadManager::instance()->download( Net::DownloadManager::instance()->download(
@ -128,18 +128,18 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result)
if (xml.isStartElement()) if (xml.isStartElement())
{ {
if (xml.name() == QLatin1String("item")) if (xml.name() == u"item")
inItem = true; inItem = true;
else if (inItem && (xml.name() == QLatin1String("link"))) else if (inItem && (xml.name() == u"link"))
updateLink = getStringValue(xml); updateLink = getStringValue(xml);
else if (inItem && (xml.name() == QLatin1String("type"))) else if (inItem && (xml.name() == u"type"))
type = getStringValue(xml); type = getStringValue(xml);
else if (inItem && (xml.name() == QLatin1String("version"))) else if (inItem && (xml.name() == u"version"))
version = getStringValue(xml); version = getStringValue(xml);
} }
else if (xml.isEndElement()) else if (xml.isEndElement())
{ {
if (inItem && (xml.name() == QLatin1String("item"))) if (inItem && (xml.name() == u"item"))
{ {
if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0) if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0)
{ {

View file

@ -188,10 +188,11 @@ void DownloadedPiecesBar::clear()
QString DownloadedPiecesBar::simpleToolTipText() const QString DownloadedPiecesBar::simpleToolTipText() const
{ {
const QString borderColor = colorBoxBorderColor().name(); const QString borderColor = colorBoxBorderColor().name();
const QString rowHTML = QString::fromLatin1("<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"); const QString rowHTML = u"<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"_qs;
return QLatin1String("<table cellspacing=4>") return u"<table cellspacing=4>"
+ rowHTML.arg(backgroundColor().name(), borderColor, tr("Missing pieces")) + rowHTML.arg(backgroundColor().name(), borderColor, tr("Missing pieces"))
+ rowHTML.arg(m_dlPieceColor.name(), borderColor, tr("Partial pieces")) + rowHTML.arg(m_dlPieceColor.name(), borderColor, tr("Partial pieces"))
+ rowHTML.arg(pieceColor().name(), borderColor, tr("Completed pieces")) + rowHTML.arg(pieceColor().name(), borderColor, tr("Completed pieces"))
+ QLatin1String("</table>"); + u"</table>";
} }

View file

@ -477,7 +477,7 @@ void PeerListWidget::updatePeer(const BitTorrent::Torrent *torrent, const BitTor
for (const Path &filePath : filePaths) for (const Path &filePath : filePaths)
downloadingFiles.append(filePath.toString()); downloadingFiles.append(filePath.toString());
const QString downloadingFilesDisplayValue = downloadingFiles.join(u';'); const QString downloadingFilesDisplayValue = downloadingFiles.join(u';');
setModelData(row, PeerListColumns::DOWNLOADING_PIECE, downloadingFilesDisplayValue, downloadingFilesDisplayValue, {}, downloadingFiles.join(QLatin1Char('\n'))); setModelData(row, PeerListColumns::DOWNLOADING_PIECE, downloadingFilesDisplayValue, downloadingFilesDisplayValue, {}, downloadingFiles.join(u'\n'));
if (m_resolver) if (m_resolver)
m_resolver->resolve(peerEndpoint.address.ip); m_resolver->resolve(peerEndpoint.address.ip);

View file

@ -168,9 +168,10 @@ void PieceAvailabilityBar::clear()
QString PieceAvailabilityBar::simpleToolTipText() const QString PieceAvailabilityBar::simpleToolTipText() const
{ {
const QString borderColor = colorBoxBorderColor().name(); const QString borderColor = colorBoxBorderColor().name();
const QString rowHTML = QString::fromLatin1("<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"); const QString rowHTML = u"<tr><td width=20 bgcolor='%1' style='border: 1px solid \"%2\";'></td><td>%3</td></tr>"_qs;
return QLatin1String("<table cellspacing=4>") return u"<table cellspacing=4>"
+ rowHTML.arg(backgroundColor().name(), borderColor, tr("Unavailable pieces")) + rowHTML.arg(backgroundColor().name(), borderColor, tr("Unavailable pieces"))
+ rowHTML.arg(pieceColor().name(), borderColor, tr("Available pieces")) + rowHTML.arg(pieceColor().name(), borderColor, tr("Available pieces"))
+ QLatin1String("</table>"); + u"</table>";
} }

View file

@ -796,7 +796,7 @@ void PropertiesWidget::configure()
delete m_speedWidget; delete m_speedWidget;
} }
const auto displayText = QString::fromLatin1("<center><b>%1</b><p>%2</p></center>") const auto displayText = u"<center><b>%1</b><p>%2</p></center>"_qs
.arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options")); .arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options"));
auto *label = new QLabel(displayText, this); auto *label = new QLabel(displayText, this);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
@ -812,7 +812,7 @@ void PropertiesWidget::askWebSeed()
// Ask user for a new url seed // Ask user for a new url seed
const QString urlSeed = AutoExpandableDialog::getText(this, tr("New URL seed", "New HTTP source"), const QString urlSeed = AutoExpandableDialog::getText(this, tr("New URL seed", "New HTTP source"),
tr("New URL seed:"), QLineEdit::Normal, tr("New URL seed:"), QLineEdit::Normal,
QLatin1String("http://www."), &ok); u"http://www."_qs, &ok);
if (!ok) return; if (!ok) return;
qDebug("Adding %s web seed", qUtf8Printable(urlSeed)); qDebug("Adding %s web seed", qUtf8Printable(urlSeed));
if (!m_ui->listWebSeeds->findItems(urlSeed, Qt::MatchFixedString).empty()) if (!m_ui->listWebSeeds->findItems(urlSeed, Qt::MatchFixedString).empty())
@ -871,7 +871,7 @@ void PropertiesWidget::editWebSeed()
if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty()) if (!m_ui->listWebSeeds->findItems(newSeed, Qt::MatchFixedString).empty())
{ {
QMessageBox::warning(this, QLatin1String("qBittorrent"), QMessageBox::warning(this, u"qBittorrent"_qs,
tr("This URL seed is already in the list."), tr("This URL seed is already in the list."),
QMessageBox::Ok); QMessageBox::Ok);
return; return;

View file

@ -105,7 +105,7 @@ void ArticleListWidget::handleArticleRead(RSS::Article *rssArticle)
const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)}; const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)};
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("sphere"))); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"sphere"_qs));
checkInvariant(); checkInvariant();
} }
@ -133,14 +133,14 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const
const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)}; const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)};
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("sphere"))); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"sphere"_qs));
} }
else else
{ {
const QColor defaultColor {palette().color(QPalette::Active, QPalette::Link)}; const QColor defaultColor {palette().color(QPalette::Active, QPalette::Link)};
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.UnreadArticle"_qs, defaultColor)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.UnreadArticle"_qs, defaultColor)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("sphere"))); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"sphere"_qs));
} }
return item; return item;

View file

@ -56,13 +56,13 @@
#include "gui/utils.h" #include "gui/utils.h"
#include "ui_automatedrssdownloader.h" #include "ui_automatedrssdownloader.h"
const QString EXT_JSON {QStringLiteral(".json")}; const QString EXT_JSON = u".json"_qs;
const QString EXT_LEGACY {QStringLiteral(".rssrules")}; const QString EXT_LEGACY = u".rssrules"_qs;
AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent)
: QDialog(parent) : QDialog(parent)
, m_formatFilterJSON(QString::fromLatin1("%1 (*%2)").arg(tr("Rules"), EXT_JSON)) , m_formatFilterJSON(u"%1 (*%2)"_qs.arg(tr("Rules"), EXT_JSON))
, m_formatFilterLegacy(QString::fromLatin1("%1 (*%2)").arg(tr("Rules (legacy)"), EXT_LEGACY)) , m_formatFilterLegacy(u"%1 (*%2)"_qs.arg(tr("Rules (legacy)"), EXT_LEGACY))
, m_ui(new Ui::AutomatedRssDownloader) , m_ui(new Ui::AutomatedRssDownloader)
, m_currentRuleItem(nullptr) , m_currentRuleItem(nullptr)
{ {
@ -431,7 +431,7 @@ void AutomatedRssDownloader::on_exportBtn_clicked()
QString selectedFilter {m_formatFilterJSON}; QString selectedFilter {m_formatFilterJSON};
Path path {QFileDialog::getSaveFileName( Path path {QFileDialog::getSaveFileName(
this, tr("Export RSS rules"), QDir::homePath() this, tr("Export RSS rules"), QDir::homePath()
, QString::fromLatin1("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter)}; , u"%1;;%2"_qs.arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter)};
if (path.isEmpty()) return; if (path.isEmpty()) return;
@ -467,7 +467,7 @@ void AutomatedRssDownloader::on_importBtn_clicked()
QString selectedFilter {m_formatFilterJSON}; QString selectedFilter {m_formatFilterJSON};
const Path path {QFileDialog::getOpenFileName( const Path path {QFileDialog::getOpenFileName(
this, tr("Import RSS rules"), QDir::homePath() this, tr("Import RSS rules"), QDir::homePath()
, QString::fromLatin1("%1;;%2").arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter)}; , u"%1;;%2"_qs.arg(m_formatFilterJSON, m_formatFilterLegacy), &selectedFilter)};
if (!path.exists()) if (!path.exists())
return; return;

View file

@ -79,11 +79,11 @@ namespace
QIcon rssFeedIcon(const RSS::Feed *feed) QIcon rssFeedIcon(const RSS::Feed *feed)
{ {
if (feed->isLoading()) if (feed->isLoading())
return UIThemeManager::instance()->getIcon(QLatin1String("loading")); return UIThemeManager::instance()->getIcon(u"loading"_qs);
if (feed->hasError()) if (feed->hasError())
return UIThemeManager::instance()->getIcon(QLatin1String("unavailable")); return UIThemeManager::instance()->getIcon(u"unavailable"_qs);
return loadIcon(feed->iconPath(), QLatin1String("application-rss+xml")); return loadIcon(feed->iconPath(), u"application-rss+xml"_qs);
} }
} }
@ -156,7 +156,7 @@ void FeedListWidget::handleItemUnreadCountChanged(RSS::Item *rssItem)
{ {
QTreeWidgetItem *item = mapRSSItem(rssItem); QTreeWidgetItem *item = mapRSSItem(rssItem);
Q_ASSERT(item); Q_ASSERT(item);
item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount()))); item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount())));
} }
} }
@ -165,7 +165,7 @@ void FeedListWidget::handleItemPathChanged(RSS::Item *rssItem)
QTreeWidgetItem *item = mapRSSItem(rssItem); QTreeWidgetItem *item = mapRSSItem(rssItem);
Q_ASSERT(item); Q_ASSERT(item);
item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount()))); item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount())));
RSS::Item *parentRssItem = RSS::Session::instance()->itemByPath(RSS::Item::parentPath(rssItem->path())); RSS::Item *parentRssItem = RSS::Session::instance()->itemByPath(RSS::Item::parentPath(rssItem->path()));
QTreeWidgetItem *parentItem = mapRSSItem(parentRssItem); QTreeWidgetItem *parentItem = mapRSSItem(parentRssItem);
@ -274,7 +274,7 @@ void FeedListWidget::dropEvent(QDropEvent *event)
QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem) QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem)
{ {
auto *item = new FeedListItem; auto *item = new FeedListItem;
item->setData(0, Qt::DisplayRole, QString::fromLatin1("%1 (%2)").arg(rssItem->name(), QString::number(rssItem->unreadCount()))); item->setData(0, Qt::DisplayRole, u"%1 (%2)"_qs.arg(rssItem->name(), QString::number(rssItem->unreadCount())));
item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem)); item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem));
m_rssToTreeItemMapping[rssItem] = item; m_rssToTreeItemMapping[rssItem] = item;
@ -282,7 +282,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem
if (auto feed = qobject_cast<RSS::Feed *>(rssItem)) if (auto feed = qobject_cast<RSS::Feed *>(rssItem))
icon = rssFeedIcon(feed); icon = rssFeedIcon(feed);
else else
icon = UIThemeManager::instance()->getIcon(QLatin1String("inode-directory")); icon = UIThemeManager::instance()->getIcon(u"inode-directory"_qs);
item->setData(0, Qt::DecorationRole, icon); item->setData(0, Qt::DecorationRole, icon);
connect(rssItem, &RSS::Item::unreadCountChanged, this, &FeedListWidget::handleItemUnreadCountChanged); connect(rssItem, &RSS::Item::unreadCountChanged, this, &FeedListWidget::handleItemUnreadCountChanged);

View file

@ -483,12 +483,12 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL
const QString alternateBaseColor = m_ui->textBrowser->palette().color(QPalette::AlternateBase).name(); const QString alternateBaseColor = m_ui->textBrowser->palette().color(QPalette::AlternateBase).name();
QString html = QString html =
QString::fromLatin1("<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>") + u"<div style='border: 2px solid red; margin-left: 5px; margin-right: 5px; margin-bottom: 5px;'>" +
QString::fromLatin1("<div style='background-color: \"%1\"; font-weight: bold; color: \"%2\";'>%3</div>").arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); u"<div style='background-color: \"%1\"; font-weight: bold; color: \"%2\";'>%3</div>"_qs.arg(highlightedBaseColor, highlightedBaseTextColor, article->title());
if (article->date().isValid()) if (article->date().isValid())
html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime())); html += u"<div style='background-color: \"%1\";'><b>%2</b>%3</div>"_qs.arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime()));
if (!article->author().isEmpty()) if (!article->author().isEmpty())
html += QString::fromLatin1("<div style='background-color: \"%1\";'><b>%2</b>%3</div>").arg(alternateBaseColor, tr("Author: "), article->author()); html += u"<div style='background-color: \"%1\";'><b>%2</b>%3</div>"_qs.arg(alternateBaseColor, tr("Author: "), article->author());
html += u"</div>" html += u"</div>"
u"<div style='margin-left: 5px; margin-right: 5px;'>"; u"<div style='margin-left: 5px; margin-right: 5px;'>";
if (Qt::mightBeRichText(article->description())) if (Qt::mightBeRichText(article->description()))

View file

@ -139,7 +139,7 @@ void PluginSelectDialog::dragEnterEvent(QDragEnterEvent *event)
qDebug("mimeData: %s", qUtf8Printable(mime)); qDebug("mimeData: %s", qUtf8Printable(mime));
} }
if (event->mimeData()->hasFormat(QLatin1String("text/plain")) || event->mimeData()->hasFormat(QLatin1String("text/uri-list"))) if (event->mimeData()->hasFormat(u"text/plain"_qs) || event->mimeData()->hasFormat(u"text/uri-list"_qs))
{ {
event->acceptProposedAction(); event->acceptProposedAction();
} }
@ -382,8 +382,7 @@ void PluginSelectDialog::askForLocalPlugin()
{ {
const QStringList pathsList = QFileDialog::getOpenFileNames( const QStringList pathsList = QFileDialog::getOpenFileNames(
nullptr, tr("Select search plugins"), QDir::homePath(), nullptr, tr("Select search plugins"), QDir::homePath(),
tr("qBittorrent search plugin") + QLatin1String(" (*.py)") (tr("qBittorrent search plugin") + u" (*.py)"));
);
for (const QString &path : pathsList) for (const QString &path : pathsList)
{ {
startAsyncOp(); startAsyncOp();
@ -414,7 +413,7 @@ void PluginSelectDialog::iconDownloadFinished(const Net::DownloadResult &result)
PluginInfo *plugin = m_pluginManager->pluginInfo(id); PluginInfo *plugin = m_pluginManager->pluginInfo(id);
if (!plugin) continue; if (!plugin) continue;
const QString ext = result.url.endsWith(QLatin1String(".ico"), Qt::CaseInsensitive) ? QLatin1String(".ico") : QLatin1String(".png"); const QString ext = result.url.endsWith(u".ico", Qt::CaseInsensitive) ? u".ico"_qs : u".png"_qs;
const Path iconPath = SearchPluginManager::pluginsLocation() / Path(id + ext); const Path iconPath = SearchPluginManager::pluginsLocation() / Path(id + ext);
if (Utils::Fs::copyFile(filePath, iconPath)) if (Utils::Fs::copyFile(filePath, iconPath))
{ {

View file

@ -52,15 +52,10 @@ void SearchSortModel::enableNameFilter(const bool enabled)
void SearchSortModel::setNameFilter(const QString &searchTerm) void SearchSortModel::setNameFilter(const QString &searchTerm)
{ {
m_searchTerm = searchTerm; m_searchTerm = searchTerm;
if ((searchTerm.length() > 2) if ((searchTerm.length() > 2) && searchTerm.startsWith(u'"') && searchTerm.endsWith(u'"'))
&& searchTerm.startsWith(QLatin1Char('"')) && searchTerm.endsWith(QLatin1Char('"')))
{
m_searchTermWords = QStringList(m_searchTerm.mid(1, m_searchTerm.length() - 2)); m_searchTermWords = QStringList(m_searchTerm.mid(1, m_searchTerm.length() - 2));
}
else else
{ m_searchTermWords = searchTerm.split(u' ', Qt::SkipEmptyParts);
m_searchTermWords = searchTerm.split(QLatin1Char(' '), Qt::SkipEmptyParts);
}
} }
void SearchSortModel::setSizeFilter(const qint64 minSize, const qint64 maxSize) void SearchSortModel::setSizeFilter(const qint64 minSize, const qint64 maxSize)

View file

@ -64,20 +64,20 @@
namespace namespace
{ {
QString statusIconName(SearchJobWidget::Status st) QString statusIconName(const SearchJobWidget::Status st)
{ {
switch (st) switch (st)
{ {
case SearchJobWidget::Status::Ongoing: case SearchJobWidget::Status::Ongoing:
return QLatin1String("task-ongoing"); return u"task-ongoing"_qs;
case SearchJobWidget::Status::Finished: case SearchJobWidget::Status::Finished:
return QLatin1String("task-complete"); return u"task-complete"_qs;
case SearchJobWidget::Status::Aborted: case SearchJobWidget::Status::Aborted:
return QLatin1String("task-reject"); return u"task-reject"_qs;
case SearchJobWidget::Status::Error: case SearchJobWidget::Status::Error:
return QLatin1String("task-attention"); return u"task-attention"_qs;
case SearchJobWidget::Status::NoResults: case SearchJobWidget::Status::NoResults:
return QLatin1String("task-attention"); return u"task-attention"_qs;
default: default:
return {}; return {};
} }

View file

@ -56,9 +56,9 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->labelGlobalSpeedIcon->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("slow_off")) m_ui->labelGlobalSpeedIcon->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"slow_off"_qs)
, this, Utils::Gui::mediumIconSize(this).height())); , this, Utils::Gui::mediumIconSize(this).height()));
m_ui->labelAltGlobalSpeedIcon->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(QLatin1String("slow")) m_ui->labelAltGlobalSpeedIcon->setPixmap(Utils::Gui::scaledPixmapSvg(UIThemeManager::instance()->getIconPath(u"slow"_qs)
, this, Utils::Gui::mediumIconSize(this).height())); , this, Utils::Gui::mediumIconSize(this).height()));
const auto initSlider = [](QSlider *slider, const int value, const int maximum) const auto initSlider = [](QSlider *slider, const int value, const int maximum)

View file

@ -90,9 +90,9 @@ void StatsDialog::update()
#ifndef QBT_USES_LIBTORRENT2 #ifndef QBT_USES_LIBTORRENT2
// Cache hits // Cache hits
const qreal readRatio = cs.readRatio; const qreal readRatio = cs.readRatio;
m_ui->labelCacheHits->setText(QString::fromLatin1("%1%").arg((readRatio > 0) m_ui->labelCacheHits->setText(u"%1%"_qs.arg((readRatio > 0)
? Utils::String::fromDouble(100 * readRatio, 2) ? Utils::String::fromDouble((100 * readRatio), 2)
: QLatin1String("0"))); : u"0"_qs));
#endif #endif
// Buffers size // Buffers size
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024)); m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024));
@ -100,12 +100,12 @@ void StatsDialog::update()
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
m_ui->labelWriteStarve->setText(QString::fromLatin1("%1%").arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0)) m_ui->labelWriteStarve->setText(u"%1%"_qs.arg(((ss.diskWriteQueue > 0) && (ss.peersCount > 0))
? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2) ? Utils::String::fromDouble((100. * ss.diskWriteQueue / ss.peersCount), 2)
: QLatin1String("0"))); : u"0"_qs));
m_ui->labelReadStarve->setText(QString::fromLatin1("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0)) m_ui->labelReadStarve->setText(u"%1%"_qs.arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0))
? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2) ? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2)
: QLatin1String("0"))); : u"0"_qs));
// Disk queues // Disk queues
m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength)); m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength));

View file

@ -63,14 +63,13 @@ StatusBar::StatusBar(QWidget *parent)
m_connecStatusLblIcon->setFlat(true); m_connecStatusLblIcon->setFlat(true);
m_connecStatusLblIcon->setFocusPolicy(Qt::NoFocus); m_connecStatusLblIcon->setFocusPolicy(Qt::NoFocus);
m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor); m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor);
m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("firewalled"))); m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"firewalled"_qs));
m_connecStatusLblIcon->setToolTip( m_connecStatusLblIcon->setToolTip(u"<b>%1</b><br><i>%2</i>"_qs.arg(tr("Connection status:")
QString::fromLatin1("<b>%1</b><br><i>%2</i>").arg(tr("Connection status:")
, tr("No direct connections. This may indicate network configuration problems."))); , tr("No direct connections. This may indicate network configuration problems.")));
connect(m_connecStatusLblIcon, &QAbstractButton::clicked, this, &StatusBar::connectionButtonClicked); connect(m_connecStatusLblIcon, &QAbstractButton::clicked, this, &StatusBar::connectionButtonClicked);
m_dlSpeedLbl = new QPushButton(this); m_dlSpeedLbl = new QPushButton(this);
m_dlSpeedLbl->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("downloading_small"))); m_dlSpeedLbl->setIcon(UIThemeManager::instance()->getIcon(u"downloading_small"_qs));
connect(m_dlSpeedLbl, &QAbstractButton::clicked, this, &StatusBar::capSpeed); connect(m_dlSpeedLbl, &QAbstractButton::clicked, this, &StatusBar::capSpeed);
m_dlSpeedLbl->setFlat(true); m_dlSpeedLbl->setFlat(true);
m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus); m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus);
@ -79,7 +78,7 @@ StatusBar::StatusBar(QWidget *parent)
m_dlSpeedLbl->setMinimumWidth(200); m_dlSpeedLbl->setMinimumWidth(200);
m_upSpeedLbl = new QPushButton(this); m_upSpeedLbl = new QPushButton(this);
m_upSpeedLbl->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("seeding"))); m_upSpeedLbl->setIcon(UIThemeManager::instance()->getIcon(u"seeding"_qs));
connect(m_upSpeedLbl, &QAbstractButton::clicked, this, &StatusBar::capSpeed); connect(m_upSpeedLbl, &QAbstractButton::clicked, this, &StatusBar::capSpeed);
m_upSpeedLbl->setFlat(true); m_upSpeedLbl->setFlat(true);
m_upSpeedLbl->setFocusPolicy(Qt::NoFocus); m_upSpeedLbl->setFocusPolicy(Qt::NoFocus);
@ -175,21 +174,24 @@ void StatusBar::updateConnectionStatus()
if (!BitTorrent::Session::instance()->isListening()) if (!BitTorrent::Session::instance()->isListening())
{ {
m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("disconnected"))); m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"disconnected"_qs));
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections.")); const QString tooltip = u"<b>%1</b><br>%2"_qs.arg(tr("Connection Status:"), tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
m_connecStatusLblIcon->setToolTip(tooltip);
} }
else else
{ {
if (sessionStatus.hasIncomingConnections) if (sessionStatus.hasIncomingConnections)
{ {
// Connection OK // Connection OK
m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("connected"))); m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"connected"_qs));
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Online")); const QString tooltip = u"<b>%1</b><br>%2"_qs.arg(tr("Connection Status:"), tr("Online"));
m_connecStatusLblIcon->setToolTip(tooltip);
} }
else else
{ {
m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("firewalled"))); m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"firewalled"_qs));
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection status:") + QLatin1String("</b><br>") + QLatin1String("<i>") + tr("No direct connections. This may indicate network configuration problems.") + QLatin1String("</i>")); const QString tooltip = u"<b>%1</b><br><i>%2</i>"_qs.arg(tr("Connection Status:"), tr("No direct connections. This may indicate network configuration problems."));
m_connecStatusLblIcon->setToolTip(tooltip);
} }
} }
} }
@ -238,13 +240,13 @@ void StatusBar::updateAltSpeedsBtn(bool alternative)
{ {
if (alternative) if (alternative)
{ {
m_altSpeedsBtn->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("slow"))); m_altSpeedsBtn->setIcon(UIThemeManager::instance()->getIcon(u"slow"_qs));
m_altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits")); m_altSpeedsBtn->setToolTip(tr("Click to switch to regular speed limits"));
m_altSpeedsBtn->setDown(true); m_altSpeedsBtn->setDown(true);
} }
else else
{ {
m_altSpeedsBtn->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("slow_off"))); m_altSpeedsBtn->setIcon(UIThemeManager::instance()->getIcon(u"slow_off"_qs));
m_altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits")); m_altSpeedsBtn->setToolTip(tr("Click to switch to alternative speed limits"));
m_altSpeedsBtn->setDown(false); m_altSpeedsBtn->setDown(false);
} }

View file

@ -41,14 +41,14 @@ namespace
{ {
QString getSpecialAllTag() QString getSpecialAllTag()
{ {
const QString ALL_TAG = QLatin1String(" "); const QString ALL_TAG = u" "_qs;
Q_ASSERT(!BitTorrent::Session::isValidTag(ALL_TAG)); Q_ASSERT(!BitTorrent::Session::isValidTag(ALL_TAG));
return ALL_TAG; return ALL_TAG;
} }
QString getSpecialUntaggedTag() QString getSpecialUntaggedTag()
{ {
const QString UNTAGGED_TAG = QLatin1String(" "); const QString UNTAGGED_TAG = u" "_qs;
Q_ASSERT(!BitTorrent::Session::isValidTag(UNTAGGED_TAG)); Q_ASSERT(!BitTorrent::Session::isValidTag(UNTAGGED_TAG));
return UNTAGGED_TAG; return UNTAGGED_TAG;
} }
@ -126,8 +126,7 @@ QVariant TagFilterModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole: case Qt::DecorationRole:
return UIThemeManager::instance()->getIcon(u"inode-directory"_qs); return UIThemeManager::instance()->getIcon(u"inode-directory"_qs);
case Qt::DisplayRole: case Qt::DisplayRole:
return QString::fromLatin1("%1 (%2)") return u"%1 (%2)"_qs.arg(tagDisplayName(item.tag())).arg(item.torrentsCount());
.arg(tagDisplayName(item.tag())).arg(item.torrentsCount());
case Qt::UserRole: case Qt::UserRole:
return item.torrentsCount(); return item.torrentsCount();
default: default:
@ -324,7 +323,7 @@ QVector<TagModelItem *> TagFilterModel::findItems(const TagSet &tags)
if (item) if (item)
items.push_back(item); items.push_back(item);
else else
qWarning() << QString::fromLatin1("Requested tag '%1' missing from the model.").arg(tag); qWarning() << u"Requested tag '%1' missing from the model."_qs.arg(tag);
} }
return items; return items;
} }

View file

@ -68,7 +68,7 @@ QString TorrentCategoryDialog::createCategory(QWidget *parent, const QString &pa
QString newCategoryName = parentCategoryName; QString newCategoryName = parentCategoryName;
if (!newCategoryName.isEmpty()) if (!newCategoryName.isEmpty())
newCategoryName += QLatin1Char('/'); newCategoryName += u'/';
newCategoryName += tr("New Category"); newCategoryName += tr("New Category");
TorrentCategoryDialog dialog {parent}; TorrentCategoryDialog dialog {parent};

View file

@ -151,13 +151,10 @@ namespace
*/ */
bool doesQFileIconProviderWork() bool doesQFileIconProviderWork()
{ {
const QString PSEUDO_UNIQUE_FILE_NAME = u"/tmp/qBittorrent-test-QFileIconProvider-845eb448-7ad5-4cdb-b764-b3f322a266a9"_qs;
QFileIconProvider provider; QFileIconProvider provider;
const char PSEUDO_UNIQUE_FILE_NAME[] = "/tmp/qBittorrent-test-QFileIconProvider-845eb448-7ad5-4cdb-b764-b3f322a266a9"; const QIcon testIcon1 = provider.icon(QFileInfo(PSEUDO_UNIQUE_FILE_NAME + u".pdf"));
QIcon testIcon1 = provider.icon(QFileInfo( const QIcon testIcon2 = provider.icon(QFileInfo(PSEUDO_UNIQUE_FILE_NAME + u".png"));
QLatin1String(PSEUDO_UNIQUE_FILE_NAME) + QLatin1String(".pdf")));
QIcon testIcon2 = provider.icon(QFileInfo(
QLatin1String(PSEUDO_UNIQUE_FILE_NAME) + QLatin1String(".png")));
return (!testIcon1.isNull() || !testIcon2.isNull()); return (!testIcon1.isNull() || !testIcon2.isNull());
} }

View file

@ -127,8 +127,8 @@ QString TorrentContentModelItem::displayData(const int column) const
} }
case COL_PROGRESS: case COL_PROGRESS:
return (m_progress >= 1) return (m_progress >= 1)
? QString::fromLatin1("100%") ? u"100%"_qs
: (Utils::String::fromDouble((m_progress * 100), 1) + QLatin1Char('%')); : (Utils::String::fromDouble((m_progress * 100), 1) + u'%');
case COL_SIZE: case COL_SIZE:
return Utils::Misc::friendlyUnit(m_size); return Utils::Misc::friendlyUnit(m_size);
case COL_REMAINING: case COL_REMAINING:
@ -140,9 +140,9 @@ QString TorrentContentModelItem::displayData(const int column) const
return tr("N/A"); return tr("N/A");
const QString value = (avail >= 1) const QString value = (avail >= 1)
? QString::fromLatin1("100") ? u"100"_qs
: Utils::String::fromDouble((avail * 100), 1); : Utils::String::fromDouble((avail * 100), 1);
return (value + C_THIN_SPACE + QLatin1Char('%')); return (value + C_THIN_SPACE + u'%');
} }
default: default:
Q_ASSERT(false); Q_ASSERT(false);

View file

@ -184,7 +184,7 @@ void TorrentCreatorDialog::onCreateButtonClicked()
} }
// get save path // get save path
const Path savePath = m_storeLastSavePath.get(Utils::Fs::homePath() / Path(inputPath.filename() + QLatin1String(".torrent"))); const Path savePath = m_storeLastSavePath.get(Utils::Fs::homePath() / Path(inputPath.filename() + u".torrent"));
Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), savePath.data(), tr("Torrent Files (*.torrent)"))}; Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), savePath.data(), tr("Torrent Files (*.torrent)"))};
if (destPath.isEmpty()) if (destPath.isEmpty())
return; return;
@ -255,7 +255,7 @@ void TorrentCreatorDialog::handleCreationSuccess(const Path &path, const Path &b
BitTorrent::Session::instance()->addTorrent(result.value(), params); BitTorrent::Session::instance()->addTorrent(result.value(), params);
} }
QMessageBox::information(this, tr("Torrent creator") QMessageBox::information(this, tr("Torrent creator")
, QString::fromLatin1("%1\n%2").arg(tr("Torrent created:"), path.toString())); , u"%1\n%2"_qs.arg(tr("Torrent created:"), path.toString()));
setInteractionEnabled(true); setInteractionEnabled(true);
} }

View file

@ -63,7 +63,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector<BitTor
: QDialog {parent} : QDialog {parent}
, m_ui {new Ui::TorrentOptionsDialog} , m_ui {new Ui::TorrentOptionsDialog}
, m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)} , m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)}
, m_currentCategoriesString {QString::fromLatin1("--%1--").arg(tr("Currently used categories"))} , m_currentCategoriesString {u"--%1--"_qs.arg(tr("Currently used categories"))}
{ {
Q_ASSERT(!torrents.empty()); Q_ASSERT(!torrents.empty());

View file

@ -172,43 +172,43 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
// Add status filters // Add status filters
auto *all = new QListWidgetItem(this); auto *all = new QListWidgetItem(this);
all->setData(Qt::DisplayRole, tr("All (0)", "this is for the status filter")); all->setData(Qt::DisplayRole, tr("All (0)", "this is for the status filter"));
all->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("filterall"))); all->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"filterall"_qs));
auto *downloading = new QListWidgetItem(this); auto *downloading = new QListWidgetItem(this);
downloading->setData(Qt::DisplayRole, tr("Downloading (0)")); downloading->setData(Qt::DisplayRole, tr("Downloading (0)"));
downloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("downloading"))); downloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"downloading"_qs));
auto *seeding = new QListWidgetItem(this); auto *seeding = new QListWidgetItem(this);
seeding->setData(Qt::DisplayRole, tr("Seeding (0)")); seeding->setData(Qt::DisplayRole, tr("Seeding (0)"));
seeding->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("uploading"))); seeding->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"uploading"_qs));
auto *completed = new QListWidgetItem(this); auto *completed = new QListWidgetItem(this);
completed->setData(Qt::DisplayRole, tr("Completed (0)")); completed->setData(Qt::DisplayRole, tr("Completed (0)"));
completed->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("completed"))); completed->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"completed"_qs));
auto *resumed = new QListWidgetItem(this); auto *resumed = new QListWidgetItem(this);
resumed->setData(Qt::DisplayRole, tr("Resumed (0)")); resumed->setData(Qt::DisplayRole, tr("Resumed (0)"));
resumed->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("resumed"))); resumed->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"resumed"_qs));
auto *paused = new QListWidgetItem(this); auto *paused = new QListWidgetItem(this);
paused->setData(Qt::DisplayRole, tr("Paused (0)")); paused->setData(Qt::DisplayRole, tr("Paused (0)"));
paused->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("paused"))); paused->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"paused"_qs));
auto *active = new QListWidgetItem(this); auto *active = new QListWidgetItem(this);
active->setData(Qt::DisplayRole, tr("Active (0)")); active->setData(Qt::DisplayRole, tr("Active (0)"));
active->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("filteractive"))); active->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"filteractive"_qs));
auto *inactive = new QListWidgetItem(this); auto *inactive = new QListWidgetItem(this);
inactive->setData(Qt::DisplayRole, tr("Inactive (0)")); inactive->setData(Qt::DisplayRole, tr("Inactive (0)"));
inactive->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("filterinactive"))); inactive->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"filterinactive"_qs));
auto *stalled = new QListWidgetItem(this); auto *stalled = new QListWidgetItem(this);
stalled->setData(Qt::DisplayRole, tr("Stalled (0)")); stalled->setData(Qt::DisplayRole, tr("Stalled (0)"));
stalled->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("filterstalled"))); stalled->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"filterstalled"_qs));
auto *stalledUploading = new QListWidgetItem(this); auto *stalledUploading = new QListWidgetItem(this);
stalledUploading->setData(Qt::DisplayRole, tr("Stalled Uploading (0)")); stalledUploading->setData(Qt::DisplayRole, tr("Stalled Uploading (0)"));
stalledUploading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("stalledUP"))); stalledUploading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"stalledUP"_qs));
auto *stalledDownloading = new QListWidgetItem(this); auto *stalledDownloading = new QListWidgetItem(this);
stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)")); stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)"));
stalledDownloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("stalledDL"))); stalledDownloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"stalledDL"_qs));
auto *checking = new QListWidgetItem(this); auto *checking = new QListWidgetItem(this);
checking->setData(Qt::DisplayRole, tr("Checking (0)")); checking->setData(Qt::DisplayRole, tr("Checking (0)"));
checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("checking"))); checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"checking"_qs));
auto *errored = new QListWidgetItem(this); auto *errored = new QListWidgetItem(this);
errored->setData(Qt::DisplayRole, tr("Errored (0)")); errored->setData(Qt::DisplayRole, tr("Errored (0)"));
errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("error"))); errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"error"_qs));
const Preferences *const pref = Preferences::instance(); const Preferences *const pref = Preferences::instance();
setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent); setCurrentRow(pref->getTransSelFilter(), QItemSelectionModel::SelectCurrent);
@ -410,7 +410,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::Torre
trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"network-server"_qs)); trackerItem->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"network-server"_qs));
const QString scheme = getScheme(tracker); const QString scheme = getScheme(tracker);
downloadFavicon(QString::fromLatin1("%1://%2/favicon.ico").arg((scheme.startsWith(u"http") ? scheme : u"http"_qs), host)); downloadFavicon(u"%1://%2/favicon.ico"_qs.arg((scheme.startsWith(u"http") ? scheme : u"http"_qs), host));
} }
if (!trackerItem) return; if (!trackerItem) return;
@ -425,7 +425,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::Torre
return; return;
} }
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(torrentIDs.size()))); trackerItem->setText(u"%1 (%2)"_qs.arg(host, QString::number(torrentIDs.size())));
if (exists) if (exists)
{ {
if (trackerFromRow(currentRow()) == host) if (trackerFromRow(currentRow()) == host)
@ -503,7 +503,7 @@ void TrackerFiltersList::removeItem(const QString &trackerURL, const BitTorrent:
} }
if (trackerItem) if (trackerItem)
trackerItem->setText(QString::fromLatin1("%1 (%2)").arg(host, QString::number(torrentIDs.size()))); trackerItem->setText(u"%1 (%2)"_qs.arg(host, QString::number(torrentIDs.size())));
} }
else else
{ {

View file

@ -72,24 +72,24 @@ namespace
const TorrentStateColorDescriptor colorDescriptors[] = const TorrentStateColorDescriptor colorDescriptors[] =
{ {
{BitTorrent::TorrentState::Downloading, QLatin1String("TransferList.Downloading")}, {BitTorrent::TorrentState::Downloading, u"TransferList.Downloading"_qs},
{BitTorrent::TorrentState::StalledDownloading, QLatin1String("TransferList.StalledDownloading")}, {BitTorrent::TorrentState::StalledDownloading, u"TransferList.StalledDownloading"_qs},
{BitTorrent::TorrentState::DownloadingMetadata, QLatin1String("TransferList.DownloadingMetadata")}, {BitTorrent::TorrentState::DownloadingMetadata, u"TransferList.DownloadingMetadata"_qs},
{BitTorrent::TorrentState::ForcedDownloadingMetadata, QLatin1String("TransferList.ForcedDownloadingMetadata")}, {BitTorrent::TorrentState::ForcedDownloadingMetadata, u"TransferList.ForcedDownloadingMetadata"_qs},
{BitTorrent::TorrentState::ForcedDownloading, QLatin1String("TransferList.ForcedDownloading")}, {BitTorrent::TorrentState::ForcedDownloading, u"TransferList.ForcedDownloading"_qs},
{BitTorrent::TorrentState::Uploading, QLatin1String("TransferList.Uploading")}, {BitTorrent::TorrentState::Uploading, u"TransferList.Uploading"_qs},
{BitTorrent::TorrentState::StalledUploading, QLatin1String("TransferList.StalledUploading")}, {BitTorrent::TorrentState::StalledUploading, u"TransferList.StalledUploading"_qs},
{BitTorrent::TorrentState::ForcedUploading, QLatin1String("TransferList.ForcedUploading")}, {BitTorrent::TorrentState::ForcedUploading, u"TransferList.ForcedUploading"_qs},
{BitTorrent::TorrentState::QueuedDownloading, QLatin1String("TransferList.QueuedDownloading")}, {BitTorrent::TorrentState::QueuedDownloading, u"TransferList.QueuedDownloading"_qs},
{BitTorrent::TorrentState::QueuedUploading, QLatin1String("TransferList.QueuedUploading")}, {BitTorrent::TorrentState::QueuedUploading, u"TransferList.QueuedUploading"_qs},
{BitTorrent::TorrentState::CheckingDownloading, QLatin1String("TransferList.CheckingDownloading")}, {BitTorrent::TorrentState::CheckingDownloading, u"TransferList.CheckingDownloading"_qs},
{BitTorrent::TorrentState::CheckingUploading, QLatin1String("TransferList.CheckingUploading")}, {BitTorrent::TorrentState::CheckingUploading, u"TransferList.CheckingUploading"_qs},
{BitTorrent::TorrentState::CheckingResumeData, QLatin1String("TransferList.CheckingResumeData")}, {BitTorrent::TorrentState::CheckingResumeData, u"TransferList.CheckingResumeData"_qs},
{BitTorrent::TorrentState::PausedDownloading, QLatin1String("TransferList.PausedDownloading")}, {BitTorrent::TorrentState::PausedDownloading, u"TransferList.PausedDownloading"_qs},
{BitTorrent::TorrentState::PausedUploading, QLatin1String("TransferList.PausedUploading")}, {BitTorrent::TorrentState::PausedUploading, u"TransferList.PausedUploading"_qs},
{BitTorrent::TorrentState::Moving, QLatin1String("TransferList.Moving")}, {BitTorrent::TorrentState::Moving, u"TransferList.Moving"_qs},
{BitTorrent::TorrentState::MissingFiles, QLatin1String("TransferList.MissingFiles")}, {BitTorrent::TorrentState::MissingFiles, u"TransferList.MissingFiles"_qs},
{BitTorrent::TorrentState::Error, QLatin1String("TransferList.Error")} {BitTorrent::TorrentState::Error, u"TransferList.Error"_qs}
}; };
QHash<BitTorrent::TorrentState, QColor> colors; QHash<BitTorrent::TorrentState, QColor> colors;
@ -273,7 +273,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
{ {
if (hideValues && (value == 0) && (total == 0)) if (hideValues && (value == 0) && (total == 0))
return {}; return {};
return QString::fromLatin1("%1 (%2)").arg(QString::number(value), QString::number(total)); return u"%1 (%2)"_qs.arg(QString::number(value), QString::number(total));
}; };
const auto etaString = [hideValues](const qlonglong value) -> QString const auto etaString = [hideValues](const qlonglong value) -> QString
@ -294,7 +294,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
const auto queuePositionString = [](const qint64 value) -> QString const auto queuePositionString = [](const qint64 value) -> QString
{ {
return (value >= 0) ? QString::number(value + 1) : QLatin1String("*"); return (value >= 0) ? QString::number(value + 1) : u"*"_qs;
}; };
const auto lastActivityString = [hideValues](qint64 value) -> QString const auto lastActivityString = [hideValues](qint64 value) -> QString
@ -328,8 +328,8 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
const auto progressString = [](const qreal progress) -> QString const auto progressString = [](const qreal progress) -> QString
{ {
return (progress >= 1) return (progress >= 1)
? QString::fromLatin1("100%") ? u"100%"_qs
: Utils::String::fromDouble((progress * 100), 1) + QLatin1Char('%'); : (Utils::String::fromDouble((progress * 100), 1) + u'%');
}; };
const auto statusString = [this](const BitTorrent::TorrentState state, const QString &errorMessage) -> QString const auto statusString = [this](const BitTorrent::TorrentState state, const QString &errorMessage) -> QString
@ -368,7 +368,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons
case TR_CATEGORY: case TR_CATEGORY:
return torrent->category(); return torrent->category();
case TR_TAGS: case TR_TAGS:
return torrent->tags().join(QLatin1String(", ")); return torrent->tags().join(u", "_qs);
case TR_ADD_DATE: case TR_ADD_DATE:
return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat); return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat);
case TR_SEED_DATE: case TR_SEED_DATE:
@ -754,55 +754,55 @@ QColor getDefaultColorByState(const BitTorrent::TorrentState state)
QIcon getPausedIcon() QIcon getPausedIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("paused")); static QIcon cached = UIThemeManager::instance()->getIcon(u"paused"_qs);
return cached; return cached;
} }
QIcon getQueuedIcon() QIcon getQueuedIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("queued")); static QIcon cached = UIThemeManager::instance()->getIcon(u"queued"_qs);
return cached; return cached;
} }
QIcon getDownloadingIcon() QIcon getDownloadingIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("downloading")); static QIcon cached = UIThemeManager::instance()->getIcon(u"downloading"_qs);
return cached; return cached;
} }
QIcon getStalledDownloadingIcon() QIcon getStalledDownloadingIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledDL")); static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledDL"_qs);
return cached; return cached;
} }
QIcon getUploadingIcon() QIcon getUploadingIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("uploading")); static QIcon cached = UIThemeManager::instance()->getIcon(u"uploading"_qs);
return cached; return cached;
} }
QIcon getStalledUploadingIcon() QIcon getStalledUploadingIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledUP")); static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledUP"_qs);
return cached; return cached;
} }
QIcon getCompletedIcon() QIcon getCompletedIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("completed")); static QIcon cached = UIThemeManager::instance()->getIcon(u"completed"_qs);
return cached; return cached;
} }
QIcon getCheckingIcon() QIcon getCheckingIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("checking")); static QIcon cached = UIThemeManager::instance()->getIcon(u"checking"_qs);
return cached; return cached;
} }
QIcon getErrorIcon() QIcon getErrorIcon()
{ {
static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("error")); static QIcon cached = UIThemeManager::instance()->getIcon(u"error"_qs);
return cached; return cached;
} }

View file

@ -46,23 +46,23 @@
namespace namespace
{ {
const Path DEFAULT_ICONS_DIR {u":icons"_qs}; const Path DEFAULT_ICONS_DIR {u":icons"_qs};
const QString CONFIG_FILE_NAME {QStringLiteral("config.json")}; const QString CONFIG_FILE_NAME = u"config.json"_qs;
const QString STYLESHEET_FILE_NAME {QStringLiteral("stylesheet.qss")}; const QString STYLESHEET_FILE_NAME = u"stylesheet.qss"_qs;
// Directory used by stylesheet to reference internal resources // Directory used by stylesheet to reference internal resources
// for example `icon: url(:/uitheme/file.svg)` will be expected to // for example `icon: url(:/uitheme/file.svg)` will be expected to
// point to a file `file.svg` in root directory of CONFIG_FILE_NAME // point to a file `file.svg` in root directory of CONFIG_FILE_NAME
const QString STYLESHEET_RESOURCES_DIR {QStringLiteral(":/uitheme")}; const QString STYLESHEET_RESOURCES_DIR = u":/uitheme"_qs;
const Path THEME_ICONS_DIR {u"icons"_qs}; const Path THEME_ICONS_DIR {u"icons"_qs};
Path findIcon(const QString &iconId, const Path &dir) Path findIcon(const QString &iconId, const Path &dir)
{ {
const Path pathSvg = dir / Path(iconId + QLatin1String(".svg")); const Path pathSvg = dir / Path(iconId + u".svg");
if (pathSvg.exists()) if (pathSvg.exists())
return pathSvg; return pathSvg;
const Path pathPng = dir / Path(iconId + QLatin1String(".png")); const Path pathPng = dir / Path(iconId + u".png");
if (pathPng.exists()) if (pathPng.exists())
return pathPng; return pathPng;
@ -142,8 +142,8 @@ namespace
if (themePath.filename() == CONFIG_FILE_NAME) if (themePath.filename() == CONFIG_FILE_NAME)
return std::make_unique<FolderThemeSource>(themePath); return std::make_unique<FolderThemeSource>(themePath);
if ((themePath.hasExtension(QLatin1String(".qbtheme"))) if ((themePath.hasExtension(u".qbtheme"_qs))
&& QResource::registerResource(themePath.data(), QLatin1String("/uitheme"))) && QResource::registerResource(themePath.data(), u"/uitheme"_qs))
{ {
return std::make_unique<QRCThemeSource>(); return std::make_unique<QRCThemeSource>();
} }
@ -231,7 +231,7 @@ QIcon UIThemeManager::getFlagIcon(const QString &countryIsoCode) const
if (iter != m_flagCache.end()) if (iter != m_flagCache.end())
return *iter; return *iter;
const QIcon icon {QLatin1String(":/icons/flags/") + key + QLatin1String(".svg")}; const QIcon icon {u":/icons/flags/" + key + u".svg"};
m_flagCache[key] = icon; m_flagCache[key] = icon;
return icon; return icon;
} }
@ -249,25 +249,25 @@ QIcon UIThemeManager::getSystrayIcon() const
{ {
#if defined(Q_OS_UNIX) #if defined(Q_OS_UNIX)
case TrayIcon::Style::Normal: case TrayIcon::Style::Normal:
return QIcon::fromTheme(QLatin1String("qbittorrent-tray")); return QIcon::fromTheme(u"qbittorrent-tray"_qs);
case TrayIcon::Style::MonoDark: case TrayIcon::Style::MonoDark:
return QIcon::fromTheme(QLatin1String("qbittorrent-tray-dark")); return QIcon::fromTheme(u"qbittorrent-tray-dark"_qs);
case TrayIcon::Style::MonoLight: case TrayIcon::Style::MonoLight:
return QIcon::fromTheme(QLatin1String("qbittorrent-tray-light")); return QIcon::fromTheme(u"qbittorrent-tray-light"_qs);
#else #else
case TrayIcon::Style::Normal: case TrayIcon::Style::Normal:
return getIcon(QLatin1String("qbittorrent-tray")); return getIcon(u"qbittorrent-tray"_qs);
case TrayIcon::Style::MonoDark: case TrayIcon::Style::MonoDark:
return getIcon(QLatin1String("qbittorrent-tray-dark")); return getIcon(u"qbittorrent-tray-dark"_qs);
case TrayIcon::Style::MonoLight: case TrayIcon::Style::MonoLight:
return getIcon(QLatin1String("qbittorrent-tray-light")); return getIcon(u"qbittorrent-tray-light"_qs);
#endif #endif
default: default:
break; break;
} }
// As a failsafe in case the enum is invalid // As a failsafe in case the enum is invalid
return getIcon(QLatin1String("qbittorrent-tray")); return getIcon(u"qbittorrent-tray"_qs);
} }
#endif #endif
@ -276,7 +276,7 @@ Path UIThemeManager::getIconPath(const QString &iconId) const
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS))
if (m_useSystemTheme) if (m_useSystemTheme)
{ {
Path path = Utils::Fs::tempPath() / Path(iconId + QLatin1String(".png")); Path path = Utils::Fs::tempPath() / Path(iconId + u".png");
if (!path.exists()) if (!path.exists())
{ {
const QIcon icon = QIcon::fromTheme(iconId); const QIcon icon = QIcon::fromTheme(iconId);
@ -354,31 +354,31 @@ void UIThemeManager::applyPalette() const
const ColorDescriptor paletteColorDescriptors[] = const ColorDescriptor paletteColorDescriptors[] =
{ {
{QLatin1String("Palette.Window"), QPalette::Window, QPalette::Normal}, {u"Palette.Window"_qs, QPalette::Window, QPalette::Normal},
{QLatin1String("Palette.WindowText"), QPalette::WindowText, QPalette::Normal}, {u"Palette.WindowText"_qs, QPalette::WindowText, QPalette::Normal},
{QLatin1String("Palette.Base"), QPalette::Base, QPalette::Normal}, {u"Palette.Base"_qs, QPalette::Base, QPalette::Normal},
{QLatin1String("Palette.AlternateBase"), QPalette::AlternateBase, QPalette::Normal}, {u"Palette.AlternateBase"_qs, QPalette::AlternateBase, QPalette::Normal},
{QLatin1String("Palette.Text"), QPalette::Text, QPalette::Normal}, {u"Palette.Text"_qs, QPalette::Text, QPalette::Normal},
{QLatin1String("Palette.ToolTipBase"), QPalette::ToolTipBase, QPalette::Normal}, {u"Palette.ToolTipBase"_qs, QPalette::ToolTipBase, QPalette::Normal},
{QLatin1String("Palette.ToolTipText"), QPalette::ToolTipText, QPalette::Normal}, {u"Palette.ToolTipText"_qs, QPalette::ToolTipText, QPalette::Normal},
{QLatin1String("Palette.BrightText"), QPalette::BrightText, QPalette::Normal}, {u"Palette.BrightText"_qs, QPalette::BrightText, QPalette::Normal},
{QLatin1String("Palette.Highlight"), QPalette::Highlight, QPalette::Normal}, {u"Palette.Highlight"_qs, QPalette::Highlight, QPalette::Normal},
{QLatin1String("Palette.HighlightedText"), QPalette::HighlightedText, QPalette::Normal}, {u"Palette.HighlightedText"_qs, QPalette::HighlightedText, QPalette::Normal},
{QLatin1String("Palette.Button"), QPalette::Button, QPalette::Normal}, {u"Palette.Button"_qs, QPalette::Button, QPalette::Normal},
{QLatin1String("Palette.ButtonText"), QPalette::ButtonText, QPalette::Normal}, {u"Palette.ButtonText"_qs, QPalette::ButtonText, QPalette::Normal},
{QLatin1String("Palette.Link"), QPalette::Link, QPalette::Normal}, {u"Palette.Link"_qs, QPalette::Link, QPalette::Normal},
{QLatin1String("Palette.LinkVisited"), QPalette::LinkVisited, QPalette::Normal}, {u"Palette.LinkVisited"_qs, QPalette::LinkVisited, QPalette::Normal},
{QLatin1String("Palette.Light"), QPalette::Light, QPalette::Normal}, {u"Palette.Light"_qs, QPalette::Light, QPalette::Normal},
{QLatin1String("Palette.Midlight"), QPalette::Midlight, QPalette::Normal}, {u"Palette.Midlight"_qs, QPalette::Midlight, QPalette::Normal},
{QLatin1String("Palette.Mid"), QPalette::Mid, QPalette::Normal}, {u"Palette.Mid"_qs, QPalette::Mid, QPalette::Normal},
{QLatin1String("Palette.Dark"), QPalette::Dark, QPalette::Normal}, {u"Palette.Dark"_qs, QPalette::Dark, QPalette::Normal},
{QLatin1String("Palette.Shadow"), QPalette::Shadow, QPalette::Normal}, {u"Palette.Shadow"_qs, QPalette::Shadow, QPalette::Normal},
{QLatin1String("Palette.WindowTextDisabled"), QPalette::WindowText, QPalette::Disabled}, {u"Palette.WindowTextDisabled"_qs, QPalette::WindowText, QPalette::Disabled},
{QLatin1String("Palette.TextDisabled"), QPalette::Text, QPalette::Disabled}, {u"Palette.TextDisabled"_qs, QPalette::Text, QPalette::Disabled},
{QLatin1String("Palette.ToolTipTextDisabled"), QPalette::ToolTipText, QPalette::Disabled}, {u"Palette.ToolTipTextDisabled"_qs, QPalette::ToolTipText, QPalette::Disabled},
{QLatin1String("Palette.BrightTextDisabled"), QPalette::BrightText, QPalette::Disabled}, {u"Palette.BrightTextDisabled"_qs, QPalette::BrightText, QPalette::Disabled},
{QLatin1String("Palette.HighlightedTextDisabled"), QPalette::HighlightedText, QPalette::Disabled}, {u"Palette.HighlightedTextDisabled"_qs, QPalette::HighlightedText, QPalette::Disabled},
{QLatin1String("Palette.ButtonTextDisabled"), QPalette::ButtonText, QPalette::Disabled} {u"Palette.ButtonTextDisabled"_qs, QPalette::ButtonText, QPalette::Disabled}
}; };
QPalette palette = qApp->palette(); QPalette palette = qApp->palette();

View file

@ -143,7 +143,7 @@ void Utils::Gui::openPath(const Path &path)
{ {
// Hack to access samba shares with QDesktopServices::openUrl // Hack to access samba shares with QDesktopServices::openUrl
if (path.data().startsWith(u"//")) if (path.data().startsWith(u"//"))
QDesktopServices::openUrl(QUrl(QString::fromLatin1("file:") + path.toString())); QDesktopServices::openUrl(QUrl(u"file:" + path.toString()));
else else
QDesktopServices::openUrl(QUrl::fromLocalFile(path.data())); QDesktopServices::openUrl(QUrl::fromLocalFile(path.data()));
} }