diff --git a/src/gui/aboutdialog.cpp b/src/gui/aboutdialog.cpp index d592124bc..9f1ca6b77 100644 --- a/src/gui/aboutdialog.cpp +++ b/src/gui/aboutdialog.cpp @@ -50,9 +50,9 @@ AboutDialog::AboutDialog(QWidget *parent) setAttribute(Qt::WA_DeleteOnClose); // Title - m_ui->labelName->setText(QString::fromLatin1("

qBittorrent " QBT_VERSION " (%1-bit)

").arg(QT_POINTER_SIZE * 8)); + m_ui->labelName->setText(QStringLiteral("

qBittorrent " QBT_VERSION " (%1-bit)

").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 const QString aboutText = diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index 75e2d66c0..c0c057060 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -45,7 +45,7 @@ namespace { - QString makeLink(const QString &url, const QString &linkLabel) + QString makeLink(const QStringView url, const QStringView linkLabel) { return u"%2"_qs.arg(url, linkLabel); } @@ -359,8 +359,8 @@ void AdvancedSettings::updateInterfaceAddressCombo() // Clear all items and reinsert them, default to all m_comboBoxInterfaceAddress.clear(); m_comboBoxInterfaceAddress.addItem(tr("All addresses"), {}); - m_comboBoxInterfaceAddress.addItem(tr("All IPv4 addresses"), QLatin1String("0.0.0.0")); - m_comboBoxInterfaceAddress.addItem(tr("All IPv6 addresses"), QLatin1String("::")); + m_comboBoxInterfaceAddress.addItem(tr("All IPv4 addresses"), u"0.0.0.0"_qs); + m_comboBoxInterfaceAddress.addItem(tr("All IPv6 addresses"), u"::"_qs); const auto populateCombo = [this](const QHostAddress &addr) { @@ -400,19 +400,19 @@ void AdvancedSettings::loadAdvancedSettings() // add section headers 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")) , this); labelQbtLink->setOpenExternalLinks(true); - addRow(QBITTORRENT_HEADER, QString::fromLatin1("%1").arg(tr("qBittorrent Section")), labelQbtLink); + addRow(QBITTORRENT_HEADER, u"%1"_qs.arg(tr("qBittorrent Section")), labelQbtLink); static_cast(cellWidget(QBITTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); 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")) , this); labelLibtorrentLink->setOpenExternalLinks(true); - addRow(LIBTORRENT_HEADER, QString::fromLatin1("%1").arg(tr("libtorrent Section")), labelLibtorrentLink); + addRow(LIBTORRENT_HEADER, u"%1"_qs.arg(tr("libtorrent Section")), labelLibtorrentLink); static_cast(cellWidget(LIBTORRENT_HEADER, PROPERTY))->setAlignment(Qt::AlignCenter | Qt::AlignVCenter); m_comboBoxResumeDataStorage.addItems({tr("Fastresume files"), tr("SQLite database (experimental)")}); @@ -443,7 +443,7 @@ void AdvancedSettings::loadAdvancedSettings() } m_comboBoxOSMemoryPriority.setCurrentIndex(OSMemoryPriorityIndex); 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_spinBoxMemoryWorkingSetLimit.setMinimum(1); @@ -452,7 +452,7 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxMemoryWorkingSetLimit.setValue(static_cast(QCoreApplication::instance())->memoryWorkingSetLimit()); 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); #endif @@ -460,7 +460,7 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxAsyncIOThreads.setMinimum(1); m_spinBoxAsyncIOThreads.setMaximum(1024); 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); #ifdef QBT_USES_LIBTORRENT2 @@ -468,7 +468,7 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxHashingThreads.setMinimum(1); m_spinBoxHashingThreads.setMaximum(1024); 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); #endif @@ -476,7 +476,7 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxFilePoolSize.setMinimum(1); m_spinBoxFilePoolSize.setMaximum(std::numeric_limits::max()); 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); // Checking Memory Usage @@ -490,7 +490,7 @@ void AdvancedSettings::loadAdvancedSettings() #endif m_spinBoxCheckingMemUsage.setValue(session->checkingMemUsage()); 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); #ifndef QBT_USES_LIBTORRENT2 // Disk write cache @@ -506,14 +506,14 @@ void AdvancedSettings::loadAdvancedSettings() updateCacheSpinSuffix(m_spinBoxCache.value()); connect(&m_spinBoxCache, qOverload(&QSpinBox::valueChanged) , 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); // Disk cache expiry m_spinBoxCacheTTL.setMinimum(1); m_spinBoxCacheTTL.setMaximum(std::numeric_limits::max()); m_spinBoxCacheTTL.setValue(session->diskCacheTTL()); 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); #endif // Disk queue size @@ -521,55 +521,55 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxDiskQueueSize.setMaximum(std::numeric_limits::max()); m_spinBoxDiskQueueSize.setValue(session->diskQueueSize() / 1024); 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); // Enable OS cache 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); #ifndef QBT_USES_LIBTORRENT2 // Coalesce reads & writes 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); #endif // Piece extent affinity 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 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); // Send buffer watermark m_spinBoxSendBufferWatermark.setMinimum(1); m_spinBoxSendBufferWatermark.setMaximum(std::numeric_limits::max()); m_spinBoxSendBufferWatermark.setSuffix(tr(" KiB")); 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_spinBoxSendBufferLowWatermark.setMinimum(1); m_spinBoxSendBufferLowWatermark.setMaximum(std::numeric_limits::max()); m_spinBoxSendBufferLowWatermark.setSuffix(tr(" KiB")); 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_spinBoxSendBufferWatermarkFactor.setMinimum(1); m_spinBoxSendBufferWatermarkFactor.setMaximum(std::numeric_limits::max()); m_spinBoxSendBufferWatermarkFactor.setSuffix(u" %"_qs); 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); // Outgoing connections per second m_spinBoxConnectionSpeed.setMinimum(0); m_spinBoxConnectionSpeed.setMaximum(std::numeric_limits::max()); 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); // Socket listen backlog size m_spinBoxSocketBacklogSize.setMinimum(1); m_spinBoxSocketBacklogSize.setMaximum(std::numeric_limits::max()); 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); // Save resume data interval m_spinBoxSaveResumeDataInterval.setMinimum(0); @@ -584,57 +584,57 @@ void AdvancedSettings::loadAdvancedSettings() m_spinBoxOutgoingPortsMin.setMaximum(65535); m_spinBoxOutgoingPortsMin.setValue(session->outgoingPortsMin()); 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); // Outgoing port Min m_spinBoxOutgoingPortsMax.setMinimum(0); m_spinBoxOutgoingPortsMax.setMaximum(65535); m_spinBoxOutgoingPortsMax.setValue(session->outgoingPortsMax()); 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); // UPnP lease duration m_spinBoxUPnPLeaseDuration.setMinimum(0); m_spinBoxUPnPLeaseDuration.setMaximum(std::numeric_limits::max()); m_spinBoxUPnPLeaseDuration.setValue(session->UPnPLeaseDuration()); 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); // Type of service m_spinBoxPeerToS.setMinimum(0); m_spinBoxPeerToS.setMaximum(255); 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); // uTP-TCP mixed mode m_comboBoxUtpMixedMode.addItems({tr("Prefer TCP"), tr("Peer proportional (throttles TCP)")}); m_comboBoxUtpMixedMode.setCurrentIndex(static_cast(session->utpMixedMode())); 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); // Support internationalized domain name (IDN) m_checkBoxIDNSupport.setChecked(session->isIDNSupportEnabled()); 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); // multiple connections per IP m_checkBoxMultiConnectionsPerIp.setChecked(session->multiConnectionsPerIpEnabled()); 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); // Validate HTTPS tracker certificate m_checkBoxValidateHTTPSTrackerCertificate.setChecked(session->validateHTTPSTrackerCertificate()); 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); // SSRF mitigation m_checkBoxSSRFMitigation.setChecked(session->isSSRFMitigationEnabled()); 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); // Disallow connection to peers on privileged ports 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 m_checkBoxRecheckCompleted.setChecked(pref->recheckTorrentsOnCompletion()); addRow(RECHECK_COMPLETED, tr("Recheck torrents on completion"), &m_checkBoxRecheckCompleted); @@ -680,17 +680,17 @@ void AdvancedSettings::loadAdvancedSettings() // Announce IP m_lineEditAnnounceIP.setText(session->announceIP()); 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); // Max concurrent HTTP announces m_spinBoxMaxConcurrentHTTPAnnounces.setMaximum(std::numeric_limits::max()); 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); // Stop tracker timeout m_spinBoxStopTrackerTimeout.setValue(session->stopTrackerTimeout()); 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); // Program notifications @@ -738,12 +738,12 @@ void AdvancedSettings::loadAdvancedSettings() // Choking algorithm m_comboBoxChokingAlgorithm.addItems({tr("Fixed slots"), tr("Upload rate based")}); m_comboBoxChokingAlgorithm.setCurrentIndex(static_cast(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); // Seed choking algorithm m_comboBoxSeedChokingAlgorithm.addItems({tr("Round-robin"), tr("Fastest upload"), tr("Anti-leech")}); m_comboBoxSeedChokingAlgorithm.setCurrentIndex(static_cast(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); // Torrent recheck confirmation @@ -757,38 +757,38 @@ void AdvancedSettings::loadAdvancedSettings() // Announce to all trackers in a tier m_checkBoxAnnounceAllTrackers.setChecked(session->announceToAllTrackers()); 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); // Announce to all tiers m_checkBoxAnnounceAllTiers.setChecked(session->announceToAllTiers()); 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_spinBoxPeerTurnover.setMinimum(0); m_spinBoxPeerTurnover.setMaximum(100); m_spinBoxPeerTurnover.setValue(session->peerTurnover()); 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_spinBoxPeerTurnoverCutoff.setMinimum(0); m_spinBoxPeerTurnoverCutoff.setMaximum(100); m_spinBoxPeerTurnoverCutoff.setSuffix(u" %"_qs); 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_spinBoxPeerTurnoverInterval.setMinimum(30); m_spinBoxPeerTurnoverInterval.setMaximum(3600); m_spinBoxPeerTurnoverInterval.setSuffix(tr(" s", " seconds")); 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); // Maximum outstanding requests to a single peer m_spinBoxRequestQueueSize.setMinimum(1); m_spinBoxRequestQueueSize.setMaximum(std::numeric_limits::max()); 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); } diff --git a/src/gui/categoryfiltermodel.cpp b/src/gui/categoryfiltermodel.cpp index 87ba579da..36ab44ccc 100644 --- a/src/gui/categoryfiltermodel.cpp +++ b/src/gui/categoryfiltermodel.cpp @@ -76,7 +76,7 @@ public: if (!m_parent || m_parent->name().isEmpty()) 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 @@ -165,7 +165,7 @@ namespace { QString shortName(const QString &fullName) { - int pos = fullName.lastIndexOf(QLatin1Char('/')); + int pos = fullName.lastIndexOf(u'/'); if (pos >= 0) return fullName.mid(pos + 1); return fullName; diff --git a/src/gui/downloadfromurldialog.cpp b/src/gui/downloadfromurldialog.cpp index 3a21cf514..7bb8bac56 100644 --- a/src/gui/downloadfromurldialog.cpp +++ b/src/gui/downloadfromurldialog.cpp @@ -88,8 +88,8 @@ DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent) uniqueURLs << str; } - const QString text = uniqueURLs.values().join(QLatin1Char('\n')) - + (!uniqueURLs.isEmpty() ? QLatin1String("\n") : QLatin1String("")); + const QString text = uniqueURLs.values().join(u'\n') + + (!uniqueURLs.isEmpty() ? u"\n" : u""); m_ui->textUrls->setText(text); m_ui->textUrls->moveCursor(QTextCursor::End); diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp index b6ad496ee..38724c767 100644 --- a/src/gui/fspathedit.cpp +++ b/src/gui/fspathedit.cpp @@ -98,10 +98,10 @@ FileSystemPathEdit::FileSystemPathEditPrivate::FileSystemPathEditPrivate( { m_browseAction->setIconText(browseButtonBriefText.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_browseBtn->setDefaultAction(m_browseAction); - m_fileNameFilter = tr("Any file") + QLatin1String(" (*)"); + m_fileNameFilter = tr("Any file") + u" (*)"; m_editor->setBrowseAction(m_browseAction); m_validator->setStrictMode(false); m_editor->setValidator(m_validator); @@ -233,18 +233,18 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val) // QFileSystemModel applies name filters to directories too. // To use the filters we have to subclass QFileSystemModel and skip directories while filtering // extract file masks - const int openBracePos = val.indexOf(QLatin1Char('('), 0); - const int closeBracePos = val.indexOf(QLatin1Char(')'), openBracePos + 1); + const int openBracePos = val.indexOf(u'('); + const int closeBracePos = val.indexOf(u')', (openBracePos + 1)); if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2)) { QString filterString = val.mid(openBracePos + 1, closeBracePos - openBracePos - 1); - if (filterString == QLatin1String("*")) + if (filterString == u"*") { // no filters d->m_editor->setFilenameFilters({}); } else { - QStringList filters = filterString.split(QLatin1Char(' '), Qt::SkipEmptyParts); + QStringList filters = filterString.split(u' ', Qt::SkipEmptyParts); d->m_editor->setFilenameFilters(filters); } } diff --git a/src/gui/lineedit.cpp b/src/gui/lineedit.cpp index 896019d40..f08069fea 100644 --- a/src/gui/lineedit.cpp +++ b/src/gui/lineedit.cpp @@ -28,7 +28,7 @@ LineEdit::LineEdit(QWidget *parent) m_searchButton->setStyleSheet(u"QToolButton {border: none; padding: 2px;}"_qs); // 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); diff --git a/src/gui/log/loglistview.cpp b/src/gui/log/loglistview.cpp index 95ec09cfd..c2494b6db 100644 --- a/src/gui/log/loglistview.cpp +++ b/src/gui/log/loglistview.cpp @@ -37,12 +37,13 @@ #include #include +#include "base/global.h" #include "gui/uithememanager.h" #include "logmodel.h" namespace { - const QString SEPARATOR = QStringLiteral(" - "); + const QString SEPARATOR = u" - "_qs; int horizontalAdvance(const QFontMetrics &fontMetrics, const QString &text) { @@ -51,8 +52,8 @@ namespace QString logText(const QModelIndex &index) { - return QString::fromLatin1("%1%2%3").arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR - , index.data(BaseLogModel::MessageRole).toString()); + return u"%1%2%3"_qs.arg(index.data(BaseLogModel::TimeRole).toString(), SEPARATOR + , index.data(BaseLogModel::MessageRole).toString()); } class LogItemDelegate final : public QStyledItemDelegate diff --git a/src/gui/log/logmodel.cpp b/src/gui/log/logmodel.cpp index 8c8d4b023..d1f69fca8 100644 --- a/src/gui/log/logmodel.cpp +++ b/src/gui/log/logmodel.cpp @@ -73,7 +73,7 @@ QVariant BaseLogModel::Message::type() const BaseLogModel::BaseLogModel(QObject *parent) : QAbstractListModel(parent) , 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) , m_foregroundForMessageTypes { - {Log::NORMAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Normal"), QApplication::palette().color(QPalette::WindowText))}, - {Log::INFO, UIThemeManager::instance()->getColor(QLatin1String("Log.Info"), Qt::blue)}, - {Log::WARNING, UIThemeManager::instance()->getColor(QLatin1String("Log.Warning"), QColor {255, 165, 0})}, // orange - {Log::CRITICAL, UIThemeManager::instance()->getColor(QLatin1String("Log.Critical"), Qt::red)} + {Log::NORMAL, UIThemeManager::instance()->getColor(u"Log.Normal"_qs, QApplication::palette().color(QPalette::WindowText))}, + {Log::INFO, UIThemeManager::instance()->getColor(u"Log.Info"_qs, Qt::blue)}, + {Log::WARNING, UIThemeManager::instance()->getColor(u"Log.Warning"_qs, QColor {255, 165, 0})}, // orange + {Log::CRITICAL, UIThemeManager::instance()->getColor(u"Log.Critical"_qs, Qt::red)} } { for (const Log::Msg &msg : asConst(Logger::instance()->getMessages())) @@ -164,7 +164,7 @@ void LogMessageModel::handleNewMessage(const Log::Msg &message) LogPeerModel::LogPeerModel(QObject *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())) handleNewMessage(peer); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 18cd09ec0..d71e782cf 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -115,9 +115,9 @@ namespace 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.startsWith(QLatin1String("file:"), Qt::CaseInsensitive) + || (!str.startsWith(u"file:", Qt::CaseInsensitive) && Net::DownloadManager::hasSupportedScheme(str)); } } @@ -1643,7 +1643,7 @@ void MainWindow::reloadSessionStats() #else 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("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))); m_systrayIcon->setToolTip(toolTip); // tray icon @@ -1674,8 +1674,8 @@ void MainWindow::showNotificationBalloon(const QString &title, const QString &ms return; #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) - OrgFreedesktopNotificationsInterface notifications(QLatin1String("org.freedesktop.Notifications") - , QLatin1String("/org/freedesktop/Notifications") + OrgFreedesktopNotificationsInterface notifications(u"org.freedesktop.Notifications"_qs + , u"/org/freedesktop/Notifications"_qs , QDBusConnection::sessionBus()); // 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 // to start their daemons at the session startup and have it sit // idling for the whole session. - const QVariantMap hints {{QLatin1String("desktop-entry"), QLatin1String("org.qbittorrent.qBittorrent")}}; - QDBusPendingReply reply = notifications.Notify(QLatin1String("qBittorrent"), 0 - , QLatin1String("qbittorrent"), title, msg, {}, hints, getNotificationTimeout()); + const QVariantMap hints {{u"desktop-entry"_qs, u"org.qbittorrent.qBittorrent"_qs}}; + QDBusPendingReply reply = notifications.Notify(u"qBittorrent"_qs, 0 + , u"qbittorrent"_qs, title, msg, {}, hints, getNotificationTimeout()); reply.waitForFinished(); 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"
" + tr("Do you want to download %1?").arg(newVersion) + u"

" - + QString::fromLatin1("%1").arg(tr("Open changelog..."))}; + + u"%1"_qs.arg(tr("Open changelog..."))}; auto *msgBox = new QMessageBox {QMessageBox::Question, tr("qBittorrent Update Available"), msg , (QMessageBox::Yes | QMessageBox::No), this}; msgBox->setAttribute(Qt::WA_DeleteOnClose); @@ -1968,7 +1968,7 @@ void MainWindow::handleUpdateCheckFinished(ProgramUpdater *updater, const bool i { 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.") , QMessageBox::Ok, this}; msgBox->setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 97c7082ea..ee6785429 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -224,18 +224,18 @@ OptionsDialog::OptionsDialog(QWidget *parent) m_ui->deleteTorrentWarningIcon->setPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical).pixmap(16, 16)); m_ui->deleteTorrentWarningIcon->hide(); m_ui->deleteTorrentWarningLabel->hide(); - m_ui->deleteTorrentWarningLabel->setToolTip(QLatin1String("

") + + m_ui->deleteTorrentWarningLabel->setToolTip(u"

" + tr("By enabling these options, you can irrevocably lose your .torrent files!") + - QLatin1String("

") + + u"

" + tr("When these options are enabled, qBittorrent will delete .torrent files " "after they were successfully (the first option) or not (the second option) added to its " "download queue. This will be applied not only to the files opened via " "“Add torrent” menu action but to those opened via file type association as well") + - QLatin1String("

") + + u"

" + tr("If you enable the second option (“Also when addition is cancelled”) the " ".torrent file will be deleted even if you press “Cancel” in " "the “Add torrent” dialog") + - QLatin1String("

")); + u"

"); m_ui->hsplitter->setCollapsible(0, 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->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton); - const QString slowTorrentsExplanation = QLatin1String("

") + const QString slowTorrentsExplanation = u"

" + tr("A torrent will be considered slow if its download and upload rates stay below these values for \"Torrent inactivity timer\" seconds") - + QLatin1String("

"); + + u"

"; m_ui->labelDownloadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); m_ui->labelUploadRateForSlowTorrents->setToolTip(slowTorrentsExplanation); m_ui->labelSlowTorrentInactivityTimer->setToolTip(slowTorrentsExplanation); @@ -482,10 +482,10 @@ OptionsDialog::OptionsDialog(QWidget *parent) #ifndef DISABLE_WEBUI // Web UI tab 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->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")); 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->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->setMode(FileSystemPathEdit::Mode::DirectorySave); @@ -661,7 +661,7 @@ void OptionsDialog::saveOptions() if (pref->getLocale() != locale) { 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)); else 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) { 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()) return; @@ -1785,13 +1785,13 @@ void OptionsDialog::webUIHttpsCertChanged(const Path &path, const ShowError show 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) { 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()) return; @@ -1811,7 +1811,7 @@ void OptionsDialog::webUIHttpsKeyChanged(const Path &path, const ShowError showE 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() diff --git a/src/gui/previewlistdelegate.cpp b/src/gui/previewlistdelegate.cpp index 6d85b0120..301d40f10 100644 --- a/src/gui/previewlistdelegate.cpp +++ b/src/gui/previewlistdelegate.cpp @@ -57,7 +57,7 @@ void PreviewListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o { const qreal progress = (index.data().toReal() * 100); const QString text = (progress >= 100) - ? QString::fromLatin1("100%") + ? u"100%"_qs : (Utils::String::fromDouble(progress, 1) + u'%'); m_progressBarPainter.paint(painter, option, text, static_cast(progress)); diff --git a/src/gui/programupdater.cpp b/src/gui/programupdater.cpp index 535b3c321..51b436600 100644 --- a/src/gui/programupdater.cpp +++ b/src/gui/programupdater.cpp @@ -60,8 +60,8 @@ namespace const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD}; if (newVersion == currentVersion) { - const bool isDevVersion = QString::fromLatin1(QBT_VERSION_STATUS).contains( - QRegularExpression(QLatin1String("(alpha|beta|rc)"))); + const bool isDevVersion = QStringLiteral(QBT_VERSION_STATUS).contains( + QRegularExpression(u"(alpha|beta|rc)"_qs)); if (isDevVersion) return true; } @@ -76,7 +76,7 @@ namespace 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, // the filehost can identify it and contact us. Net::DownloadManager::instance()->download( @@ -128,18 +128,18 @@ void ProgramUpdater::rssDownloadFinished(const Net::DownloadResult &result) if (xml.isStartElement()) { - if (xml.name() == QLatin1String("item")) + if (xml.name() == u"item") inItem = true; - else if (inItem && (xml.name() == QLatin1String("link"))) + else if (inItem && (xml.name() == u"link")) updateLink = getStringValue(xml); - else if (inItem && (xml.name() == QLatin1String("type"))) + else if (inItem && (xml.name() == u"type")) type = getStringValue(xml); - else if (inItem && (xml.name() == QLatin1String("version"))) + else if (inItem && (xml.name() == u"version")) version = getStringValue(xml); } else if (xml.isEndElement()) { - if (inItem && (xml.name() == QLatin1String("item"))) + if (inItem && (xml.name() == u"item")) { if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0) { diff --git a/src/gui/properties/downloadedpiecesbar.cpp b/src/gui/properties/downloadedpiecesbar.cpp index 322432120..31535889d 100644 --- a/src/gui/properties/downloadedpiecesbar.cpp +++ b/src/gui/properties/downloadedpiecesbar.cpp @@ -188,10 +188,11 @@ void DownloadedPiecesBar::clear() QString DownloadedPiecesBar::simpleToolTipText() const { const QString borderColor = colorBoxBorderColor().name(); - const QString rowHTML = QString::fromLatin1("%3"); - return QLatin1String("") + const QString rowHTML = u""_qs; + return u"
%3
" + rowHTML.arg(backgroundColor().name(), borderColor, tr("Missing pieces")) + rowHTML.arg(m_dlPieceColor.name(), borderColor, tr("Partial pieces")) + rowHTML.arg(pieceColor().name(), borderColor, tr("Completed pieces")) - + QLatin1String("
"); + + u""; + } diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index 841674722..ca6a275ef 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -477,7 +477,7 @@ void PeerListWidget::updatePeer(const BitTorrent::Torrent *torrent, const BitTor for (const Path &filePath : filePaths) downloadingFiles.append(filePath.toString()); 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) m_resolver->resolve(peerEndpoint.address.ip); diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index 4156dfd1a..e0944b127 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -168,9 +168,10 @@ void PieceAvailabilityBar::clear() QString PieceAvailabilityBar::simpleToolTipText() const { const QString borderColor = colorBoxBorderColor().name(); - const QString rowHTML = QString::fromLatin1("%3"); - return QLatin1String("") + const QString rowHTML = u""_qs; + return u"
%3
" + rowHTML.arg(backgroundColor().name(), borderColor, tr("Unavailable pieces")) + rowHTML.arg(pieceColor().name(), borderColor, tr("Available pieces")) - + QLatin1String("
"); + + u""; + } diff --git a/src/gui/properties/propertieswidget.cpp b/src/gui/properties/propertieswidget.cpp index d40fa53b5..a6c21caa4 100644 --- a/src/gui/properties/propertieswidget.cpp +++ b/src/gui/properties/propertieswidget.cpp @@ -796,7 +796,7 @@ void PropertiesWidget::configure() delete m_speedWidget; } - const auto displayText = QString::fromLatin1("
%1

%2

") + const auto displayText = u"
%1

%2

"_qs .arg(tr("Speed graphs are disabled"), tr("You can enable it in Advanced Options")); auto *label = new QLabel(displayText, this); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); @@ -812,7 +812,7 @@ void PropertiesWidget::askWebSeed() // Ask user for a new url seed const QString urlSeed = AutoExpandableDialog::getText(this, tr("New URL seed", "New HTTP source"), tr("New URL seed:"), QLineEdit::Normal, - QLatin1String("http://www."), &ok); + u"http://www."_qs, &ok); if (!ok) return; qDebug("Adding %s web seed", qUtf8Printable(urlSeed)); 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()) { - QMessageBox::warning(this, QLatin1String("qBittorrent"), + QMessageBox::warning(this, u"qBittorrent"_qs, tr("This URL seed is already in the list."), QMessageBox::Ok); return; diff --git a/src/gui/rss/articlelistwidget.cpp b/src/gui/rss/articlelistwidget.cpp index 1dbe8addc..64d32635c 100644 --- a/src/gui/rss/articlelistwidget.cpp +++ b/src/gui/rss/articlelistwidget.cpp @@ -105,7 +105,7 @@ void ArticleListWidget::handleArticleRead(RSS::Article *rssArticle) const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)}; 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(); } @@ -133,14 +133,14 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const const QColor defaultColor {palette().color(QPalette::Inactive, QPalette::WindowText)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_qs, defaultColor)}; 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 { const QColor defaultColor {palette().color(QPalette::Active, QPalette::Link)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.UnreadArticle"_qs, defaultColor)}; 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; diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 989cb46d9..f5f80ff2b 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -56,13 +56,13 @@ #include "gui/utils.h" #include "ui_automatedrssdownloader.h" -const QString EXT_JSON {QStringLiteral(".json")}; -const QString EXT_LEGACY {QStringLiteral(".rssrules")}; +const QString EXT_JSON = u".json"_qs; +const QString EXT_LEGACY = u".rssrules"_qs; AutomatedRssDownloader::AutomatedRssDownloader(QWidget *parent) : QDialog(parent) - , m_formatFilterJSON(QString::fromLatin1("%1 (*%2)").arg(tr("Rules"), EXT_JSON)) - , m_formatFilterLegacy(QString::fromLatin1("%1 (*%2)").arg(tr("Rules (legacy)"), EXT_LEGACY)) + , m_formatFilterJSON(u"%1 (*%2)"_qs.arg(tr("Rules"), EXT_JSON)) + , m_formatFilterLegacy(u"%1 (*%2)"_qs.arg(tr("Rules (legacy)"), EXT_LEGACY)) , m_ui(new Ui::AutomatedRssDownloader) , m_currentRuleItem(nullptr) { @@ -431,7 +431,7 @@ void AutomatedRssDownloader::on_exportBtn_clicked() QString selectedFilter {m_formatFilterJSON}; Path path {QFileDialog::getSaveFileName( 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; @@ -467,7 +467,7 @@ void AutomatedRssDownloader::on_importBtn_clicked() QString selectedFilter {m_formatFilterJSON}; const Path path {QFileDialog::getOpenFileName( 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()) return; diff --git a/src/gui/rss/feedlistwidget.cpp b/src/gui/rss/feedlistwidget.cpp index 44ba23d63..681fc840a 100644 --- a/src/gui/rss/feedlistwidget.cpp +++ b/src/gui/rss/feedlistwidget.cpp @@ -79,11 +79,11 @@ namespace QIcon rssFeedIcon(const RSS::Feed *feed) { if (feed->isLoading()) - return UIThemeManager::instance()->getIcon(QLatin1String("loading")); + return UIThemeManager::instance()->getIcon(u"loading"_qs); 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); 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); 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())); QTreeWidgetItem *parentItem = mapRSSItem(parentRssItem); @@ -274,7 +274,7 @@ void FeedListWidget::dropEvent(QDropEvent *event) QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem) { 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(rssItem)); m_rssToTreeItemMapping[rssItem] = item; @@ -282,7 +282,7 @@ QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem if (auto feed = qobject_cast(rssItem)) icon = rssFeedIcon(feed); else - icon = UIThemeManager::instance()->getIcon(QLatin1String("inode-directory")); + icon = UIThemeManager::instance()->getIcon(u"inode-directory"_qs); item->setData(0, Qt::DecorationRole, icon); connect(rssItem, &RSS::Item::unreadCountChanged, this, &FeedListWidget::handleItemUnreadCountChanged); diff --git a/src/gui/rss/rsswidget.cpp b/src/gui/rss/rsswidget.cpp index 71e923ab0..b1d637ccf 100644 --- a/src/gui/rss/rsswidget.cpp +++ b/src/gui/rss/rsswidget.cpp @@ -483,12 +483,12 @@ void RSSWidget::handleCurrentArticleItemChanged(QListWidgetItem *currentItem, QL const QString alternateBaseColor = m_ui->textBrowser->palette().color(QPalette::AlternateBase).name(); QString html = - QString::fromLatin1("
") + - QString::fromLatin1("
%3
").arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); + u"
" + + u"
%3
"_qs.arg(highlightedBaseColor, highlightedBaseTextColor, article->title()); if (article->date().isValid()) - html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime())); + html += u"
%2%3
"_qs.arg(alternateBaseColor, tr("Date: "), QLocale::system().toString(article->date().toLocalTime())); if (!article->author().isEmpty()) - html += QString::fromLatin1("
%2%3
").arg(alternateBaseColor, tr("Author: "), article->author()); + html += u"
%2%3
"_qs.arg(alternateBaseColor, tr("Author: "), article->author()); html += u"
" u"
"; if (Qt::mightBeRichText(article->description())) diff --git a/src/gui/search/pluginselectdialog.cpp b/src/gui/search/pluginselectdialog.cpp index ca8b68862..0e9b39d50 100644 --- a/src/gui/search/pluginselectdialog.cpp +++ b/src/gui/search/pluginselectdialog.cpp @@ -139,7 +139,7 @@ void PluginSelectDialog::dragEnterEvent(QDragEnterEvent *event) 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(); } @@ -382,8 +382,7 @@ void PluginSelectDialog::askForLocalPlugin() { const QStringList pathsList = QFileDialog::getOpenFileNames( nullptr, tr("Select search plugins"), QDir::homePath(), - tr("qBittorrent search plugin") + QLatin1String(" (*.py)") - ); + (tr("qBittorrent search plugin") + u" (*.py)")); for (const QString &path : pathsList) { startAsyncOp(); @@ -414,7 +413,7 @@ void PluginSelectDialog::iconDownloadFinished(const Net::DownloadResult &result) PluginInfo *plugin = m_pluginManager->pluginInfo(id); 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); if (Utils::Fs::copyFile(filePath, iconPath)) { diff --git a/src/gui/search/searchsortmodel.cpp b/src/gui/search/searchsortmodel.cpp index 6ab343632..671b594eb 100644 --- a/src/gui/search/searchsortmodel.cpp +++ b/src/gui/search/searchsortmodel.cpp @@ -52,15 +52,10 @@ void SearchSortModel::enableNameFilter(const bool enabled) void SearchSortModel::setNameFilter(const QString &searchTerm) { m_searchTerm = searchTerm; - if ((searchTerm.length() > 2) - && searchTerm.startsWith(QLatin1Char('"')) && searchTerm.endsWith(QLatin1Char('"'))) - { + if ((searchTerm.length() > 2) && searchTerm.startsWith(u'"') && searchTerm.endsWith(u'"')) m_searchTermWords = QStringList(m_searchTerm.mid(1, m_searchTerm.length() - 2)); - } else - { - m_searchTermWords = searchTerm.split(QLatin1Char(' '), Qt::SkipEmptyParts); - } + m_searchTermWords = searchTerm.split(u' ', Qt::SkipEmptyParts); } void SearchSortModel::setSizeFilter(const qint64 minSize, const qint64 maxSize) diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 0a5b10651..34fb88c91 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -64,20 +64,20 @@ namespace { - QString statusIconName(SearchJobWidget::Status st) + QString statusIconName(const SearchJobWidget::Status st) { switch (st) { case SearchJobWidget::Status::Ongoing: - return QLatin1String("task-ongoing"); + return u"task-ongoing"_qs; case SearchJobWidget::Status::Finished: - return QLatin1String("task-complete"); + return u"task-complete"_qs; case SearchJobWidget::Status::Aborted: - return QLatin1String("task-reject"); + return u"task-reject"_qs; case SearchJobWidget::Status::Error: - return QLatin1String("task-attention"); + return u"task-attention"_qs; case SearchJobWidget::Status::NoResults: - return QLatin1String("task-attention"); + return u"task-attention"_qs; default: return {}; } diff --git a/src/gui/speedlimitdialog.cpp b/src/gui/speedlimitdialog.cpp index ea7b68809..3a95bc95f 100644 --- a/src/gui/speedlimitdialog.cpp +++ b/src/gui/speedlimitdialog.cpp @@ -56,9 +56,9 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) { 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())); - 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())); const auto initSlider = [](QSlider *slider, const int value, const int maximum) diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index 1e9fc12f1..a6dd64c24 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -90,9 +90,9 @@ void StatsDialog::update() #ifndef QBT_USES_LIBTORRENT2 // Cache hits const qreal readRatio = cs.readRatio; - m_ui->labelCacheHits->setText(QString::fromLatin1("%1%").arg((readRatio > 0) - ? Utils::String::fromDouble(100 * readRatio, 2) - : QLatin1String("0"))); + m_ui->labelCacheHits->setText(u"%1%"_qs.arg((readRatio > 0) + ? Utils::String::fromDouble((100 * readRatio), 2) + : u"0"_qs)); #endif // Buffers size 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 // 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) - : QLatin1String("0"))); - m_ui->labelReadStarve->setText(QString::fromLatin1("%1%").arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0)) + : u"0"_qs)); + m_ui->labelReadStarve->setText(u"%1%"_qs.arg(((ss.diskReadQueue > 0) && (ss.peersCount > 0)) ? Utils::String::fromDouble((100. * ss.diskReadQueue / ss.peersCount), 2) - : QLatin1String("0"))); + : u"0"_qs)); // Disk queues m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength)); diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index 4710b48a4..bb287cce0 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -63,14 +63,13 @@ StatusBar::StatusBar(QWidget *parent) m_connecStatusLblIcon->setFlat(true); m_connecStatusLblIcon->setFocusPolicy(Qt::NoFocus); m_connecStatusLblIcon->setCursor(Qt::PointingHandCursor); - m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("firewalled"))); - m_connecStatusLblIcon->setToolTip( - QString::fromLatin1("%1
%2").arg(tr("Connection status:") - , tr("No direct connections. This may indicate network configuration problems."))); + m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"firewalled"_qs)); + m_connecStatusLblIcon->setToolTip(u"%1
%2"_qs.arg(tr("Connection status:") + , tr("No direct connections. This may indicate network configuration problems."))); connect(m_connecStatusLblIcon, &QAbstractButton::clicked, this, &StatusBar::connectionButtonClicked); 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); m_dlSpeedLbl->setFlat(true); m_dlSpeedLbl->setFocusPolicy(Qt::NoFocus); @@ -79,7 +78,7 @@ StatusBar::StatusBar(QWidget *parent) m_dlSpeedLbl->setMinimumWidth(200); 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); m_upSpeedLbl->setFlat(true); m_upSpeedLbl->setFocusPolicy(Qt::NoFocus); @@ -175,21 +174,24 @@ void StatusBar::updateConnectionStatus() if (!BitTorrent::Session::instance()->isListening()) { - m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("disconnected"))); - m_connecStatusLblIcon->setToolTip(QLatin1String("") + tr("Connection Status:") + QLatin1String("
") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections.")); + m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"disconnected"_qs)); + const QString tooltip = u"%1
%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 { if (sessionStatus.hasIncomingConnections) { // Connection OK - m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("connected"))); - m_connecStatusLblIcon->setToolTip(QLatin1String("") + tr("Connection Status:") + QLatin1String("
") + tr("Online")); + m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"connected"_qs)); + const QString tooltip = u"%1
%2"_qs.arg(tr("Connection Status:"), tr("Online")); + m_connecStatusLblIcon->setToolTip(tooltip); } else { - m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(QLatin1String("firewalled"))); - m_connecStatusLblIcon->setToolTip(QLatin1String("") + tr("Connection status:") + QLatin1String("
") + QLatin1String("") + tr("No direct connections. This may indicate network configuration problems.") + QLatin1String("")); + m_connecStatusLblIcon->setIcon(UIThemeManager::instance()->getIcon(u"firewalled"_qs)); + const QString tooltip = u"%1
%2"_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) { - 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->setDown(true); } 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->setDown(false); } diff --git a/src/gui/tagfiltermodel.cpp b/src/gui/tagfiltermodel.cpp index 8cdac0369..ce56328d9 100644 --- a/src/gui/tagfiltermodel.cpp +++ b/src/gui/tagfiltermodel.cpp @@ -41,14 +41,14 @@ namespace { QString getSpecialAllTag() { - const QString ALL_TAG = QLatin1String(" "); + const QString ALL_TAG = u" "_qs; Q_ASSERT(!BitTorrent::Session::isValidTag(ALL_TAG)); return ALL_TAG; } QString getSpecialUntaggedTag() { - const QString UNTAGGED_TAG = QLatin1String(" "); + const QString UNTAGGED_TAG = u" "_qs; Q_ASSERT(!BitTorrent::Session::isValidTag(UNTAGGED_TAG)); return UNTAGGED_TAG; } @@ -126,8 +126,7 @@ QVariant TagFilterModel::data(const QModelIndex &index, int role) const case Qt::DecorationRole: return UIThemeManager::instance()->getIcon(u"inode-directory"_qs); case Qt::DisplayRole: - return QString::fromLatin1("%1 (%2)") - .arg(tagDisplayName(item.tag())).arg(item.torrentsCount()); + return u"%1 (%2)"_qs.arg(tagDisplayName(item.tag())).arg(item.torrentsCount()); case Qt::UserRole: return item.torrentsCount(); default: @@ -324,7 +323,7 @@ QVector TagFilterModel::findItems(const TagSet &tags) if (item) items.push_back(item); 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; } diff --git a/src/gui/torrentcategorydialog.cpp b/src/gui/torrentcategorydialog.cpp index ef78db009..34cdce354 100644 --- a/src/gui/torrentcategorydialog.cpp +++ b/src/gui/torrentcategorydialog.cpp @@ -68,7 +68,7 @@ QString TorrentCategoryDialog::createCategory(QWidget *parent, const QString &pa QString newCategoryName = parentCategoryName; if (!newCategoryName.isEmpty()) - newCategoryName += QLatin1Char('/'); + newCategoryName += u'/'; newCategoryName += tr("New Category"); TorrentCategoryDialog dialog {parent}; diff --git a/src/gui/torrentcontentmodel.cpp b/src/gui/torrentcontentmodel.cpp index ffb9b36a4..0fe41bf24 100644 --- a/src/gui/torrentcontentmodel.cpp +++ b/src/gui/torrentcontentmodel.cpp @@ -151,13 +151,10 @@ namespace */ bool doesQFileIconProviderWork() { + const QString PSEUDO_UNIQUE_FILE_NAME = u"/tmp/qBittorrent-test-QFileIconProvider-845eb448-7ad5-4cdb-b764-b3f322a266a9"_qs; QFileIconProvider provider; - const char PSEUDO_UNIQUE_FILE_NAME[] = "/tmp/qBittorrent-test-QFileIconProvider-845eb448-7ad5-4cdb-b764-b3f322a266a9"; - QIcon testIcon1 = provider.icon(QFileInfo( - QLatin1String(PSEUDO_UNIQUE_FILE_NAME) + QLatin1String(".pdf"))); - QIcon testIcon2 = provider.icon(QFileInfo( - QLatin1String(PSEUDO_UNIQUE_FILE_NAME) + QLatin1String(".png"))); - + const QIcon testIcon1 = provider.icon(QFileInfo(PSEUDO_UNIQUE_FILE_NAME + u".pdf")); + const QIcon testIcon2 = provider.icon(QFileInfo(PSEUDO_UNIQUE_FILE_NAME + u".png")); return (!testIcon1.isNull() || !testIcon2.isNull()); } diff --git a/src/gui/torrentcontentmodelitem.cpp b/src/gui/torrentcontentmodelitem.cpp index 62731312a..ae14a2d60 100644 --- a/src/gui/torrentcontentmodelitem.cpp +++ b/src/gui/torrentcontentmodelitem.cpp @@ -127,8 +127,8 @@ QString TorrentContentModelItem::displayData(const int column) const } case COL_PROGRESS: return (m_progress >= 1) - ? QString::fromLatin1("100%") - : (Utils::String::fromDouble((m_progress * 100), 1) + QLatin1Char('%')); + ? u"100%"_qs + : (Utils::String::fromDouble((m_progress * 100), 1) + u'%'); case COL_SIZE: return Utils::Misc::friendlyUnit(m_size); case COL_REMAINING: @@ -140,9 +140,9 @@ QString TorrentContentModelItem::displayData(const int column) const return tr("N/A"); const QString value = (avail >= 1) - ? QString::fromLatin1("100") + ? u"100"_qs : Utils::String::fromDouble((avail * 100), 1); - return (value + C_THIN_SPACE + QLatin1Char('%')); + return (value + C_THIN_SPACE + u'%'); } default: Q_ASSERT(false); diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index d1b2213a5..0f822a345 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -184,7 +184,7 @@ void TorrentCreatorDialog::onCreateButtonClicked() } // 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)"))}; if (destPath.isEmpty()) return; @@ -255,7 +255,7 @@ void TorrentCreatorDialog::handleCreationSuccess(const Path &path, const Path &b BitTorrent::Session::instance()->addTorrent(result.value(), params); } 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); } diff --git a/src/gui/torrentoptionsdialog.cpp b/src/gui/torrentoptionsdialog.cpp index aee253172..ea5968865 100644 --- a/src/gui/torrentoptionsdialog.cpp +++ b/src/gui/torrentoptionsdialog.cpp @@ -63,7 +63,7 @@ TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVectorsetData(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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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(); 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)); 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; @@ -425,7 +425,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const BitTorrent::Torre 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 (trackerFromRow(currentRow()) == host) @@ -503,7 +503,7 @@ void TrackerFiltersList::removeItem(const QString &trackerURL, const BitTorrent: } 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 { diff --git a/src/gui/transferlistmodel.cpp b/src/gui/transferlistmodel.cpp index 8b0511254..197d8f176 100644 --- a/src/gui/transferlistmodel.cpp +++ b/src/gui/transferlistmodel.cpp @@ -72,24 +72,24 @@ namespace const TorrentStateColorDescriptor colorDescriptors[] = { - {BitTorrent::TorrentState::Downloading, QLatin1String("TransferList.Downloading")}, - {BitTorrent::TorrentState::StalledDownloading, QLatin1String("TransferList.StalledDownloading")}, - {BitTorrent::TorrentState::DownloadingMetadata, QLatin1String("TransferList.DownloadingMetadata")}, - {BitTorrent::TorrentState::ForcedDownloadingMetadata, QLatin1String("TransferList.ForcedDownloadingMetadata")}, - {BitTorrent::TorrentState::ForcedDownloading, QLatin1String("TransferList.ForcedDownloading")}, - {BitTorrent::TorrentState::Uploading, QLatin1String("TransferList.Uploading")}, - {BitTorrent::TorrentState::StalledUploading, QLatin1String("TransferList.StalledUploading")}, - {BitTorrent::TorrentState::ForcedUploading, QLatin1String("TransferList.ForcedUploading")}, - {BitTorrent::TorrentState::QueuedDownloading, QLatin1String("TransferList.QueuedDownloading")}, - {BitTorrent::TorrentState::QueuedUploading, QLatin1String("TransferList.QueuedUploading")}, - {BitTorrent::TorrentState::CheckingDownloading, QLatin1String("TransferList.CheckingDownloading")}, - {BitTorrent::TorrentState::CheckingUploading, QLatin1String("TransferList.CheckingUploading")}, - {BitTorrent::TorrentState::CheckingResumeData, QLatin1String("TransferList.CheckingResumeData")}, - {BitTorrent::TorrentState::PausedDownloading, QLatin1String("TransferList.PausedDownloading")}, - {BitTorrent::TorrentState::PausedUploading, QLatin1String("TransferList.PausedUploading")}, - {BitTorrent::TorrentState::Moving, QLatin1String("TransferList.Moving")}, - {BitTorrent::TorrentState::MissingFiles, QLatin1String("TransferList.MissingFiles")}, - {BitTorrent::TorrentState::Error, QLatin1String("TransferList.Error")} + {BitTorrent::TorrentState::Downloading, u"TransferList.Downloading"_qs}, + {BitTorrent::TorrentState::StalledDownloading, u"TransferList.StalledDownloading"_qs}, + {BitTorrent::TorrentState::DownloadingMetadata, u"TransferList.DownloadingMetadata"_qs}, + {BitTorrent::TorrentState::ForcedDownloadingMetadata, u"TransferList.ForcedDownloadingMetadata"_qs}, + {BitTorrent::TorrentState::ForcedDownloading, u"TransferList.ForcedDownloading"_qs}, + {BitTorrent::TorrentState::Uploading, u"TransferList.Uploading"_qs}, + {BitTorrent::TorrentState::StalledUploading, u"TransferList.StalledUploading"_qs}, + {BitTorrent::TorrentState::ForcedUploading, u"TransferList.ForcedUploading"_qs}, + {BitTorrent::TorrentState::QueuedDownloading, u"TransferList.QueuedDownloading"_qs}, + {BitTorrent::TorrentState::QueuedUploading, u"TransferList.QueuedUploading"_qs}, + {BitTorrent::TorrentState::CheckingDownloading, u"TransferList.CheckingDownloading"_qs}, + {BitTorrent::TorrentState::CheckingUploading, u"TransferList.CheckingUploading"_qs}, + {BitTorrent::TorrentState::CheckingResumeData, u"TransferList.CheckingResumeData"_qs}, + {BitTorrent::TorrentState::PausedDownloading, u"TransferList.PausedDownloading"_qs}, + {BitTorrent::TorrentState::PausedUploading, u"TransferList.PausedUploading"_qs}, + {BitTorrent::TorrentState::Moving, u"TransferList.Moving"_qs}, + {BitTorrent::TorrentState::MissingFiles, u"TransferList.MissingFiles"_qs}, + {BitTorrent::TorrentState::Error, u"TransferList.Error"_qs} }; QHash colors; @@ -273,7 +273,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons { if (hideValues && (value == 0) && (total == 0)) 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 @@ -294,7 +294,7 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons 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 @@ -328,8 +328,8 @@ QString TransferListModel::displayValue(const BitTorrent::Torrent *torrent, cons const auto progressString = [](const qreal progress) -> QString { return (progress >= 1) - ? QString::fromLatin1("100%") - : Utils::String::fromDouble((progress * 100), 1) + QLatin1Char('%'); + ? u"100%"_qs + : (Utils::String::fromDouble((progress * 100), 1) + u'%'); }; 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: return torrent->category(); case TR_TAGS: - return torrent->tags().join(QLatin1String(", ")); + return torrent->tags().join(u", "_qs); case TR_ADD_DATE: return QLocale().toString(torrent->addedTime().toLocalTime(), QLocale::ShortFormat); case TR_SEED_DATE: @@ -754,55 +754,55 @@ QColor getDefaultColorByState(const BitTorrent::TorrentState state) QIcon getPausedIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("paused")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"paused"_qs); return cached; } QIcon getQueuedIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("queued")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"queued"_qs); return cached; } QIcon getDownloadingIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("downloading")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"downloading"_qs); return cached; } QIcon getStalledDownloadingIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledDL")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledDL"_qs); return cached; } QIcon getUploadingIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("uploading")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"uploading"_qs); return cached; } QIcon getStalledUploadingIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("stalledUP")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"stalledUP"_qs); return cached; } QIcon getCompletedIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("completed")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"completed"_qs); return cached; } QIcon getCheckingIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("checking")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"checking"_qs); return cached; } QIcon getErrorIcon() { - static QIcon cached = UIThemeManager::instance()->getIcon(QLatin1String("error")); + static QIcon cached = UIThemeManager::instance()->getIcon(u"error"_qs); return cached; } diff --git a/src/gui/uithememanager.cpp b/src/gui/uithememanager.cpp index a1c7ce6e1..4e8aa6933 100644 --- a/src/gui/uithememanager.cpp +++ b/src/gui/uithememanager.cpp @@ -46,23 +46,23 @@ namespace { const Path DEFAULT_ICONS_DIR {u":icons"_qs}; - const QString CONFIG_FILE_NAME {QStringLiteral("config.json")}; - const QString STYLESHEET_FILE_NAME {QStringLiteral("stylesheet.qss")}; + const QString CONFIG_FILE_NAME = u"config.json"_qs; + const QString STYLESHEET_FILE_NAME = u"stylesheet.qss"_qs; // Directory used by stylesheet to reference internal resources // for example `icon: url(:/uitheme/file.svg)` will be expected to // 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}; 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()) return pathSvg; - const Path pathPng = dir / Path(iconId + QLatin1String(".png")); + const Path pathPng = dir / Path(iconId + u".png"); if (pathPng.exists()) return pathPng; @@ -142,8 +142,8 @@ namespace if (themePath.filename() == CONFIG_FILE_NAME) return std::make_unique(themePath); - if ((themePath.hasExtension(QLatin1String(".qbtheme"))) - && QResource::registerResource(themePath.data(), QLatin1String("/uitheme"))) + if ((themePath.hasExtension(u".qbtheme"_qs)) + && QResource::registerResource(themePath.data(), u"/uitheme"_qs)) { return std::make_unique(); } @@ -231,7 +231,7 @@ QIcon UIThemeManager::getFlagIcon(const QString &countryIsoCode) const if (iter != m_flagCache.end()) return *iter; - const QIcon icon {QLatin1String(":/icons/flags/") + key + QLatin1String(".svg")}; + const QIcon icon {u":/icons/flags/" + key + u".svg"}; m_flagCache[key] = icon; return icon; } @@ -249,25 +249,25 @@ QIcon UIThemeManager::getSystrayIcon() const { #if defined(Q_OS_UNIX) case TrayIcon::Style::Normal: - return QIcon::fromTheme(QLatin1String("qbittorrent-tray")); + return QIcon::fromTheme(u"qbittorrent-tray"_qs); case TrayIcon::Style::MonoDark: - return QIcon::fromTheme(QLatin1String("qbittorrent-tray-dark")); + return QIcon::fromTheme(u"qbittorrent-tray-dark"_qs); case TrayIcon::Style::MonoLight: - return QIcon::fromTheme(QLatin1String("qbittorrent-tray-light")); + return QIcon::fromTheme(u"qbittorrent-tray-light"_qs); #else case TrayIcon::Style::Normal: - return getIcon(QLatin1String("qbittorrent-tray")); + return getIcon(u"qbittorrent-tray"_qs); case TrayIcon::Style::MonoDark: - return getIcon(QLatin1String("qbittorrent-tray-dark")); + return getIcon(u"qbittorrent-tray-dark"_qs); case TrayIcon::Style::MonoLight: - return getIcon(QLatin1String("qbittorrent-tray-light")); + return getIcon(u"qbittorrent-tray-light"_qs); #endif default: break; } // As a failsafe in case the enum is invalid - return getIcon(QLatin1String("qbittorrent-tray")); + return getIcon(u"qbittorrent-tray"_qs); } #endif @@ -276,7 +276,7 @@ Path UIThemeManager::getIconPath(const QString &iconId) const #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) if (m_useSystemTheme) { - Path path = Utils::Fs::tempPath() / Path(iconId + QLatin1String(".png")); + Path path = Utils::Fs::tempPath() / Path(iconId + u".png"); if (!path.exists()) { const QIcon icon = QIcon::fromTheme(iconId); @@ -354,31 +354,31 @@ void UIThemeManager::applyPalette() const const ColorDescriptor paletteColorDescriptors[] = { - {QLatin1String("Palette.Window"), QPalette::Window, QPalette::Normal}, - {QLatin1String("Palette.WindowText"), QPalette::WindowText, QPalette::Normal}, - {QLatin1String("Palette.Base"), QPalette::Base, QPalette::Normal}, - {QLatin1String("Palette.AlternateBase"), QPalette::AlternateBase, QPalette::Normal}, - {QLatin1String("Palette.Text"), QPalette::Text, QPalette::Normal}, - {QLatin1String("Palette.ToolTipBase"), QPalette::ToolTipBase, QPalette::Normal}, - {QLatin1String("Palette.ToolTipText"), QPalette::ToolTipText, QPalette::Normal}, - {QLatin1String("Palette.BrightText"), QPalette::BrightText, QPalette::Normal}, - {QLatin1String("Palette.Highlight"), QPalette::Highlight, QPalette::Normal}, - {QLatin1String("Palette.HighlightedText"), QPalette::HighlightedText, QPalette::Normal}, - {QLatin1String("Palette.Button"), QPalette::Button, QPalette::Normal}, - {QLatin1String("Palette.ButtonText"), QPalette::ButtonText, QPalette::Normal}, - {QLatin1String("Palette.Link"), QPalette::Link, QPalette::Normal}, - {QLatin1String("Palette.LinkVisited"), QPalette::LinkVisited, QPalette::Normal}, - {QLatin1String("Palette.Light"), QPalette::Light, QPalette::Normal}, - {QLatin1String("Palette.Midlight"), QPalette::Midlight, QPalette::Normal}, - {QLatin1String("Palette.Mid"), QPalette::Mid, QPalette::Normal}, - {QLatin1String("Palette.Dark"), QPalette::Dark, QPalette::Normal}, - {QLatin1String("Palette.Shadow"), QPalette::Shadow, QPalette::Normal}, - {QLatin1String("Palette.WindowTextDisabled"), QPalette::WindowText, QPalette::Disabled}, - {QLatin1String("Palette.TextDisabled"), QPalette::Text, QPalette::Disabled}, - {QLatin1String("Palette.ToolTipTextDisabled"), QPalette::ToolTipText, QPalette::Disabled}, - {QLatin1String("Palette.BrightTextDisabled"), QPalette::BrightText, QPalette::Disabled}, - {QLatin1String("Palette.HighlightedTextDisabled"), QPalette::HighlightedText, QPalette::Disabled}, - {QLatin1String("Palette.ButtonTextDisabled"), QPalette::ButtonText, QPalette::Disabled} + {u"Palette.Window"_qs, QPalette::Window, QPalette::Normal}, + {u"Palette.WindowText"_qs, QPalette::WindowText, QPalette::Normal}, + {u"Palette.Base"_qs, QPalette::Base, QPalette::Normal}, + {u"Palette.AlternateBase"_qs, QPalette::AlternateBase, QPalette::Normal}, + {u"Palette.Text"_qs, QPalette::Text, QPalette::Normal}, + {u"Palette.ToolTipBase"_qs, QPalette::ToolTipBase, QPalette::Normal}, + {u"Palette.ToolTipText"_qs, QPalette::ToolTipText, QPalette::Normal}, + {u"Palette.BrightText"_qs, QPalette::BrightText, QPalette::Normal}, + {u"Palette.Highlight"_qs, QPalette::Highlight, QPalette::Normal}, + {u"Palette.HighlightedText"_qs, QPalette::HighlightedText, QPalette::Normal}, + {u"Palette.Button"_qs, QPalette::Button, QPalette::Normal}, + {u"Palette.ButtonText"_qs, QPalette::ButtonText, QPalette::Normal}, + {u"Palette.Link"_qs, QPalette::Link, QPalette::Normal}, + {u"Palette.LinkVisited"_qs, QPalette::LinkVisited, QPalette::Normal}, + {u"Palette.Light"_qs, QPalette::Light, QPalette::Normal}, + {u"Palette.Midlight"_qs, QPalette::Midlight, QPalette::Normal}, + {u"Palette.Mid"_qs, QPalette::Mid, QPalette::Normal}, + {u"Palette.Dark"_qs, QPalette::Dark, QPalette::Normal}, + {u"Palette.Shadow"_qs, QPalette::Shadow, QPalette::Normal}, + {u"Palette.WindowTextDisabled"_qs, QPalette::WindowText, QPalette::Disabled}, + {u"Palette.TextDisabled"_qs, QPalette::Text, QPalette::Disabled}, + {u"Palette.ToolTipTextDisabled"_qs, QPalette::ToolTipText, QPalette::Disabled}, + {u"Palette.BrightTextDisabled"_qs, QPalette::BrightText, QPalette::Disabled}, + {u"Palette.HighlightedTextDisabled"_qs, QPalette::HighlightedText, QPalette::Disabled}, + {u"Palette.ButtonTextDisabled"_qs, QPalette::ButtonText, QPalette::Disabled} }; QPalette palette = qApp->palette(); diff --git a/src/gui/utils.cpp b/src/gui/utils.cpp index de5bedccd..82a19d904 100644 --- a/src/gui/utils.cpp +++ b/src/gui/utils.cpp @@ -143,7 +143,7 @@ void Utils::Gui::openPath(const Path &path) { // Hack to access samba shares with QDesktopServices::openUrl if (path.data().startsWith(u"//")) - QDesktopServices::openUrl(QUrl(QString::fromLatin1("file:") + path.toString())); + QDesktopServices::openUrl(QUrl(u"file:" + path.toString())); else QDesktopServices::openUrl(QUrl::fromLocalFile(path.data())); }