diff --git a/src/app/application.cpp b/src/app/application.cpp index f69b630da..d3b99d19c 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -101,8 +101,8 @@ namespace { -#define SETTINGS_KEY(name) "Application/" name -#define FILELOGGER_SETTINGS_KEY(name) (SETTINGS_KEY("FileLogger/") name) +#define SETTINGS_KEY(name) u"Application/" name +#define FILELOGGER_SETTINGS_KEY(name) (SETTINGS_KEY(u"FileLogger/") name) const QString LOG_FOLDER = u"logs"_qs; const QChar PARAMS_SEPARATOR = u'|'; @@ -124,15 +124,15 @@ Application::Application(int &argc, char **argv) , m_shutdownAct(ShutdownDialogAction::Exit) , m_commandLineArgs(parseCommandLine(this->arguments())) #ifdef Q_OS_WIN - , m_storeMemoryWorkingSetLimit(SETTINGS_KEY("MemoryWorkingSetLimit")) + , m_storeMemoryWorkingSetLimit(SETTINGS_KEY(u"MemoryWorkingSetLimit"_qs)) #endif - , m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY("Enabled")) - , m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY("Backup")) - , m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY("DeleteOld")) - , m_storeFileLoggerMaxSize(FILELOGGER_SETTINGS_KEY("MaxSizeBytes")) - , m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY("Age")) - , m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY("AgeType")) - , m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY("Path")) + , m_storeFileLoggerEnabled(FILELOGGER_SETTINGS_KEY(u"Enabled"_qs)) + , m_storeFileLoggerBackup(FILELOGGER_SETTINGS_KEY(u"Backup"_qs)) + , m_storeFileLoggerDeleteOld(FILELOGGER_SETTINGS_KEY(u"DeleteOld"_qs)) + , m_storeFileLoggerMaxSize(FILELOGGER_SETTINGS_KEY(u"MaxSizeBytes"_qs)) + , m_storeFileLoggerAge(FILELOGGER_SETTINGS_KEY(u"Age"_qs)) + , m_storeFileLoggerAgeType(FILELOGGER_SETTINGS_KEY(u"AgeType"_qs)) + , m_storeFileLoggerPath(FILELOGGER_SETTINGS_KEY(u"Path"_qs)) { qRegisterMetaType("Log::Msg"); qRegisterMetaType("Log::Peer"); diff --git a/src/app/filelogger.cpp b/src/app/filelogger.cpp index 34ceffb4e..3d2b002a3 100644 --- a/src/app/filelogger.cpp +++ b/src/app/filelogger.cpp @@ -152,12 +152,12 @@ void FileLogger::addLogMessage(const Log::Msg &msg) { closeLogFile(); int counter = 0; - Path backupLogFilename = m_path + ".bak"; + Path backupLogFilename = m_path + u".bak"; while (backupLogFilename.exists()) { ++counter; - backupLogFilename = m_path + ".bak" + QString::number(counter); + backupLogFilename = m_path + u".bak" + QString::number(counter); } Utils::Fs::renameFile(m_path, backupLogFilename); diff --git a/src/app/upgrade.cpp b/src/app/upgrade.cpp index a9d7087ce..1121f43be 100644 --- a/src/app/upgrade.cpp +++ b/src/app/upgrade.cpp @@ -45,7 +45,7 @@ namespace { const int MIGRATION_VERSION = 3; - const char MIGRATION_VERSION_KEY[] = "Meta/MigrationVersion"; + const QString MIGRATION_VERSION_KEY = u"Meta/MigrationVersion"_qs; void exportWebUIHttpsFiles() { @@ -400,7 +400,7 @@ bool upgrade(const bool /*ask*/) void setCurrentMigrationVersion() { - SettingsStorage::instance()->storeValue(QString::fromLatin1(MIGRATION_VERSION_KEY), MIGRATION_VERSION); + SettingsStorage::instance()->storeValue(MIGRATION_VERSION_KEY, MIGRATION_VERSION); } void handleChangedDefaults(const DefaultPreferencesMode mode) diff --git a/src/base/bittorrent/portforwarderimpl.cpp b/src/base/bittorrent/portforwarderimpl.cpp index 91e72d808..738d473a8 100644 --- a/src/base/bittorrent/portforwarderimpl.cpp +++ b/src/base/bittorrent/portforwarderimpl.cpp @@ -36,7 +36,7 @@ PortForwarderImpl::PortForwarderImpl(lt::session *provider, QObject *parent) : Net::PortForwarder {parent} - , m_storeActive {"Network/PortForwardingEnabled", true} + , m_storeActive {u"Network/PortForwardingEnabled"_qs, true} , m_provider {provider} { if (isEnabled()) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index e73aa7229..de1aa89bf 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -361,119 +361,119 @@ const int addTorrentParamsId = qRegisterMetaType(); Session *Session::m_instance = nullptr; -#define BITTORRENT_KEY(name) "BitTorrent/" name -#define BITTORRENT_SESSION_KEY(name) BITTORRENT_KEY("Session/") name +#define BITTORRENT_KEY(name) u"BitTorrent/" name +#define BITTORRENT_SESSION_KEY(name) BITTORRENT_KEY(u"Session/") name Session::Session(QObject *parent) : QObject(parent) - , m_isDHTEnabled(BITTORRENT_SESSION_KEY("DHTEnabled"), true) - , m_isLSDEnabled(BITTORRENT_SESSION_KEY("LSDEnabled"), true) - , m_isPeXEnabled(BITTORRENT_SESSION_KEY("PeXEnabled"), true) - , m_isIPFilteringEnabled(BITTORRENT_SESSION_KEY("IPFilteringEnabled"), false) - , m_isTrackerFilteringEnabled(BITTORRENT_SESSION_KEY("TrackerFilteringEnabled"), false) - , m_IPFilterFile(BITTORRENT_SESSION_KEY("IPFilter")) - , m_announceToAllTrackers(BITTORRENT_SESSION_KEY("AnnounceToAllTrackers"), false) - , m_announceToAllTiers(BITTORRENT_SESSION_KEY("AnnounceToAllTiers"), true) - , m_asyncIOThreads(BITTORRENT_SESSION_KEY("AsyncIOThreadsCount"), 10) - , m_hashingThreads(BITTORRENT_SESSION_KEY("HashingThreadsCount"), 2) - , m_filePoolSize(BITTORRENT_SESSION_KEY("FilePoolSize"), 5000) - , m_checkingMemUsage(BITTORRENT_SESSION_KEY("CheckingMemUsageSize"), 32) - , m_diskCacheSize(BITTORRENT_SESSION_KEY("DiskCacheSize"), -1) - , m_diskCacheTTL(BITTORRENT_SESSION_KEY("DiskCacheTTL"), 60) - , m_diskQueueSize(BITTORRENT_SESSION_KEY("DiskQueueSize"), (1024 * 1024)) - , m_useOSCache(BITTORRENT_SESSION_KEY("UseOSCache"), true) + , m_isDHTEnabled(BITTORRENT_SESSION_KEY(u"DHTEnabled"_qs), true) + , m_isLSDEnabled(BITTORRENT_SESSION_KEY(u"LSDEnabled"_qs), true) + , m_isPeXEnabled(BITTORRENT_SESSION_KEY(u"PeXEnabled"_qs), true) + , m_isIPFilteringEnabled(BITTORRENT_SESSION_KEY(u"IPFilteringEnabled"_qs), false) + , m_isTrackerFilteringEnabled(BITTORRENT_SESSION_KEY(u"TrackerFilteringEnabled"_qs), false) + , m_IPFilterFile(BITTORRENT_SESSION_KEY(u"IPFilter"_qs)) + , m_announceToAllTrackers(BITTORRENT_SESSION_KEY(u"AnnounceToAllTrackers"_qs), false) + , m_announceToAllTiers(BITTORRENT_SESSION_KEY(u"AnnounceToAllTiers"_qs), true) + , m_asyncIOThreads(BITTORRENT_SESSION_KEY(u"AsyncIOThreadsCount"_qs), 10) + , m_hashingThreads(BITTORRENT_SESSION_KEY(u"HashingThreadsCount"_qs), 2) + , m_filePoolSize(BITTORRENT_SESSION_KEY(u"FilePoolSize"_qs), 5000) + , m_checkingMemUsage(BITTORRENT_SESSION_KEY(u"CheckingMemUsageSize"_qs), 32) + , m_diskCacheSize(BITTORRENT_SESSION_KEY(u"DiskCacheSize"_qs), -1) + , m_diskCacheTTL(BITTORRENT_SESSION_KEY(u"DiskCacheTTL"_qs), 60) + , m_diskQueueSize(BITTORRENT_SESSION_KEY(u"DiskQueueSize"_qs), (1024 * 1024)) + , m_useOSCache(BITTORRENT_SESSION_KEY(u"UseOSCache"_qs), true) #ifdef Q_OS_WIN - , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), true) + , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY(u"CoalesceReadWrite"_qs), true) #else - , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY("CoalesceReadWrite"), false) + , m_coalesceReadWriteEnabled(BITTORRENT_SESSION_KEY(u"CoalesceReadWrite"_qs), false) #endif - , m_usePieceExtentAffinity(BITTORRENT_SESSION_KEY("PieceExtentAffinity"), false) - , m_isSuggestMode(BITTORRENT_SESSION_KEY("SuggestMode"), false) - , m_sendBufferWatermark(BITTORRENT_SESSION_KEY("SendBufferWatermark"), 500) - , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY("SendBufferLowWatermark"), 10) - , m_sendBufferWatermarkFactor(BITTORRENT_SESSION_KEY("SendBufferWatermarkFactor"), 50) - , m_connectionSpeed(BITTORRENT_SESSION_KEY("ConnectionSpeed"), 30) - , m_socketBacklogSize(BITTORRENT_SESSION_KEY("SocketBacklogSize"), 30) - , m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY("AnonymousModeEnabled"), false) - , m_isQueueingEnabled(BITTORRENT_SESSION_KEY("QueueingSystemEnabled"), false) - , m_maxActiveDownloads(BITTORRENT_SESSION_KEY("MaxActiveDownloads"), 3, lowerLimited(-1)) - , m_maxActiveUploads(BITTORRENT_SESSION_KEY("MaxActiveUploads"), 3, lowerLimited(-1)) - , m_maxActiveTorrents(BITTORRENT_SESSION_KEY("MaxActiveTorrents"), 5, lowerLimited(-1)) - , m_ignoreSlowTorrentsForQueueing(BITTORRENT_SESSION_KEY("IgnoreSlowTorrentsForQueueing"), false) - , m_downloadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsDownloadRate"), 2) - , m_uploadRateForSlowTorrents(BITTORRENT_SESSION_KEY("SlowTorrentsUploadRate"), 2) - , m_slowTorrentsInactivityTimer(BITTORRENT_SESSION_KEY("SlowTorrentsInactivityTimer"), 60) - , m_outgoingPortsMin(BITTORRENT_SESSION_KEY("OutgoingPortsMin"), 0) - , m_outgoingPortsMax(BITTORRENT_SESSION_KEY("OutgoingPortsMax"), 0) - , m_UPnPLeaseDuration(BITTORRENT_SESSION_KEY("UPnPLeaseDuration"), 0) - , m_peerToS(BITTORRENT_SESSION_KEY("PeerToS"), 0x04) - , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY("IgnoreLimitsOnLAN"), false) - , m_includeOverheadInLimits(BITTORRENT_SESSION_KEY("IncludeOverheadInLimits"), false) - , m_announceIP(BITTORRENT_SESSION_KEY("AnnounceIP")) - , m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY("MaxConcurrentHTTPAnnounces"), 50) - , m_isReannounceWhenAddressChangedEnabled(BITTORRENT_SESSION_KEY("ReannounceWhenAddressChanged"), false) - , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY("StopTrackerTimeout"), 5) - , m_maxConnections(BITTORRENT_SESSION_KEY("MaxConnections"), 500, lowerLimited(0, -1)) - , m_maxUploads(BITTORRENT_SESSION_KEY("MaxUploads"), 20, lowerLimited(0, -1)) - , m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY("MaxConnectionsPerTorrent"), 100, lowerLimited(0, -1)) - , m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY("MaxUploadsPerTorrent"), 4, lowerLimited(0, -1)) - , m_btProtocol(BITTORRENT_SESSION_KEY("BTProtocol"), BTProtocol::Both + , m_usePieceExtentAffinity(BITTORRENT_SESSION_KEY(u"PieceExtentAffinity"_qs), false) + , m_isSuggestMode(BITTORRENT_SESSION_KEY(u"SuggestMode"_qs), false) + , m_sendBufferWatermark(BITTORRENT_SESSION_KEY(u"SendBufferWatermark"_qs), 500) + , m_sendBufferLowWatermark(BITTORRENT_SESSION_KEY(u"SendBufferLowWatermark"_qs), 10) + , m_sendBufferWatermarkFactor(BITTORRENT_SESSION_KEY(u"SendBufferWatermarkFactor"_qs), 50) + , m_connectionSpeed(BITTORRENT_SESSION_KEY(u"ConnectionSpeed"_qs), 30) + , m_socketBacklogSize(BITTORRENT_SESSION_KEY(u"SocketBacklogSize"_qs), 30) + , m_isAnonymousModeEnabled(BITTORRENT_SESSION_KEY(u"AnonymousModeEnabled"_qs), false) + , m_isQueueingEnabled(BITTORRENT_SESSION_KEY(u"QueueingSystemEnabled"_qs), false) + , m_maxActiveDownloads(BITTORRENT_SESSION_KEY(u"MaxActiveDownloads"_qs), 3, lowerLimited(-1)) + , m_maxActiveUploads(BITTORRENT_SESSION_KEY(u"MaxActiveUploads"_qs), 3, lowerLimited(-1)) + , m_maxActiveTorrents(BITTORRENT_SESSION_KEY(u"MaxActiveTorrents"_qs), 5, lowerLimited(-1)) + , m_ignoreSlowTorrentsForQueueing(BITTORRENT_SESSION_KEY(u"IgnoreSlowTorrentsForQueueing"_qs), false) + , m_downloadRateForSlowTorrents(BITTORRENT_SESSION_KEY(u"SlowTorrentsDownloadRate"_qs), 2) + , m_uploadRateForSlowTorrents(BITTORRENT_SESSION_KEY(u"SlowTorrentsUploadRate"_qs), 2) + , m_slowTorrentsInactivityTimer(BITTORRENT_SESSION_KEY(u"SlowTorrentsInactivityTimer"_qs), 60) + , m_outgoingPortsMin(BITTORRENT_SESSION_KEY(u"OutgoingPortsMin"_qs), 0) + , m_outgoingPortsMax(BITTORRENT_SESSION_KEY(u"OutgoingPortsMax"_qs), 0) + , m_UPnPLeaseDuration(BITTORRENT_SESSION_KEY(u"UPnPLeaseDuration"_qs), 0) + , m_peerToS(BITTORRENT_SESSION_KEY(u"PeerToS"_qs), 0x04) + , m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY(u"IgnoreLimitsOnLAN"_qs), false) + , m_includeOverheadInLimits(BITTORRENT_SESSION_KEY(u"IncludeOverheadInLimits"_qs), false) + , m_announceIP(BITTORRENT_SESSION_KEY(u"AnnounceIP"_qs)) + , m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY(u"MaxConcurrentHTTPAnnounces"_qs), 50) + , m_isReannounceWhenAddressChangedEnabled(BITTORRENT_SESSION_KEY(u"ReannounceWhenAddressChanged"_qs), false) + , m_stopTrackerTimeout(BITTORRENT_SESSION_KEY(u"StopTrackerTimeout"_qs), 5) + , m_maxConnections(BITTORRENT_SESSION_KEY(u"MaxConnections"_qs), 500, lowerLimited(0, -1)) + , m_maxUploads(BITTORRENT_SESSION_KEY(u"MaxUploads"_qs), 20, lowerLimited(0, -1)) + , m_maxConnectionsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxConnectionsPerTorrent"_qs), 100, lowerLimited(0, -1)) + , m_maxUploadsPerTorrent(BITTORRENT_SESSION_KEY(u"MaxUploadsPerTorrent"_qs), 4, lowerLimited(0, -1)) + , m_btProtocol(BITTORRENT_SESSION_KEY(u"BTProtocol"_qs), BTProtocol::Both , clampValue(BTProtocol::Both, BTProtocol::UTP)) - , m_isUTPRateLimited(BITTORRENT_SESSION_KEY("uTPRateLimited"), true) - , m_utpMixedMode(BITTORRENT_SESSION_KEY("uTPMixedMode"), MixedModeAlgorithm::TCP + , m_isUTPRateLimited(BITTORRENT_SESSION_KEY(u"uTPRateLimited"_qs), true) + , m_utpMixedMode(BITTORRENT_SESSION_KEY(u"uTPMixedMode"_qs), MixedModeAlgorithm::TCP , clampValue(MixedModeAlgorithm::TCP, MixedModeAlgorithm::Proportional)) - , m_IDNSupportEnabled(BITTORRENT_SESSION_KEY("IDNSupportEnabled"), false) - , m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY("MultiConnectionsPerIp"), false) - , m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY("ValidateHTTPSTrackerCertificate"), true) - , m_SSRFMitigationEnabled(BITTORRENT_SESSION_KEY("SSRFMitigation"), true) - , m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY("BlockPeersOnPrivilegedPorts"), false) - , m_isAddTrackersEnabled(BITTORRENT_SESSION_KEY("AddTrackersEnabled"), false) - , m_additionalTrackers(BITTORRENT_SESSION_KEY("AdditionalTrackers")) - , m_globalMaxRatio(BITTORRENT_SESSION_KEY("GlobalMaxRatio"), -1, [](qreal r) { return r < 0 ? -1. : r;}) - , m_globalMaxSeedingMinutes(BITTORRENT_SESSION_KEY("GlobalMaxSeedingMinutes"), -1, lowerLimited(-1)) - , m_isAddTorrentPaused(BITTORRENT_SESSION_KEY("AddTorrentPaused"), false) - , m_torrentContentLayout(BITTORRENT_SESSION_KEY("TorrentContentLayout"), TorrentContentLayout::Original) - , m_isAppendExtensionEnabled(BITTORRENT_SESSION_KEY("AddExtensionToIncompleteFiles"), false) - , m_refreshInterval(BITTORRENT_SESSION_KEY("RefreshInterval"), 1500) - , m_isPreallocationEnabled(BITTORRENT_SESSION_KEY("Preallocation"), false) - , m_torrentExportDirectory(BITTORRENT_SESSION_KEY("TorrentExportDirectory")) - , m_finishedTorrentExportDirectory(BITTORRENT_SESSION_KEY("FinishedTorrentExportDirectory")) - , m_globalDownloadSpeedLimit(BITTORRENT_SESSION_KEY("GlobalDLSpeedLimit"), 0, lowerLimited(0)) - , m_globalUploadSpeedLimit(BITTORRENT_SESSION_KEY("GlobalUPSpeedLimit"), 0, lowerLimited(0)) - , m_altGlobalDownloadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalDLSpeedLimit"), 10, lowerLimited(0)) - , m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY("AlternativeGlobalUPSpeedLimit"), 10, lowerLimited(0)) - , m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY("UseAlternativeGlobalSpeedLimit"), false) - , m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY("BandwidthSchedulerEnabled"), false) - , m_isPerformanceWarningEnabled(BITTORRENT_SESSION_KEY("PerformanceWarning"), false) - , m_saveResumeDataInterval(BITTORRENT_SESSION_KEY("SaveResumeDataInterval"), 60) - , m_port(BITTORRENT_SESSION_KEY("Port"), -1) - , m_networkInterface(BITTORRENT_SESSION_KEY("Interface")) - , m_networkInterfaceName(BITTORRENT_SESSION_KEY("InterfaceName")) - , m_networkInterfaceAddress(BITTORRENT_SESSION_KEY("InterfaceAddress")) - , m_encryption(BITTORRENT_SESSION_KEY("Encryption"), 0) - , m_maxActiveCheckingTorrents(BITTORRENT_SESSION_KEY("MaxActiveCheckingTorrents"), 1) - , m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY("ProxyPeerConnections"), false) - , m_chokingAlgorithm(BITTORRENT_SESSION_KEY("ChokingAlgorithm"), ChokingAlgorithm::FixedSlots + , m_IDNSupportEnabled(BITTORRENT_SESSION_KEY(u"IDNSupportEnabled"_qs), false) + , m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY(u"MultiConnectionsPerIp"_qs), false) + , m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY(u"ValidateHTTPSTrackerCertificate"_qs), true) + , m_SSRFMitigationEnabled(BITTORRENT_SESSION_KEY(u"SSRFMitigation"_qs), true) + , m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY(u"BlockPeersOnPrivilegedPorts"_qs), false) + , m_isAddTrackersEnabled(BITTORRENT_SESSION_KEY(u"AddTrackersEnabled"_qs), false) + , m_additionalTrackers(BITTORRENT_SESSION_KEY(u"AdditionalTrackers"_qs)) + , m_globalMaxRatio(BITTORRENT_SESSION_KEY(u"GlobalMaxRatio"_qs), -1, [](qreal r) { return r < 0 ? -1. : r;}) + , m_globalMaxSeedingMinutes(BITTORRENT_SESSION_KEY(u"GlobalMaxSeedingMinutes"_qs), -1, lowerLimited(-1)) + , m_isAddTorrentPaused(BITTORRENT_SESSION_KEY(u"AddTorrentPaused"_qs), false) + , m_torrentContentLayout(BITTORRENT_SESSION_KEY(u"TorrentContentLayout"_qs), TorrentContentLayout::Original) + , m_isAppendExtensionEnabled(BITTORRENT_SESSION_KEY(u"AddExtensionToIncompleteFiles"_qs), false) + , m_refreshInterval(BITTORRENT_SESSION_KEY(u"RefreshInterval"_qs), 1500) + , m_isPreallocationEnabled(BITTORRENT_SESSION_KEY(u"Preallocation"_qs), false) + , m_torrentExportDirectory(BITTORRENT_SESSION_KEY(u"TorrentExportDirectory"_qs)) + , m_finishedTorrentExportDirectory(BITTORRENT_SESSION_KEY(u"FinishedTorrentExportDirectory"_qs)) + , m_globalDownloadSpeedLimit(BITTORRENT_SESSION_KEY(u"GlobalDLSpeedLimit"_qs), 0, lowerLimited(0)) + , m_globalUploadSpeedLimit(BITTORRENT_SESSION_KEY(u"GlobalUPSpeedLimit"_qs), 0, lowerLimited(0)) + , m_altGlobalDownloadSpeedLimit(BITTORRENT_SESSION_KEY(u"AlternativeGlobalDLSpeedLimit"_qs), 10, lowerLimited(0)) + , m_altGlobalUploadSpeedLimit(BITTORRENT_SESSION_KEY(u"AlternativeGlobalUPSpeedLimit"_qs), 10, lowerLimited(0)) + , m_isAltGlobalSpeedLimitEnabled(BITTORRENT_SESSION_KEY(u"UseAlternativeGlobalSpeedLimit"_qs), false) + , m_isBandwidthSchedulerEnabled(BITTORRENT_SESSION_KEY(u"BandwidthSchedulerEnabled"_qs), false) + , m_isPerformanceWarningEnabled(BITTORRENT_SESSION_KEY(u"PerformanceWarning"_qs), false) + , m_saveResumeDataInterval(BITTORRENT_SESSION_KEY(u"SaveResumeDataInterval"_qs), 60) + , m_port(BITTORRENT_SESSION_KEY(u"Port"_qs), -1) + , m_networkInterface(BITTORRENT_SESSION_KEY(u"Interface"_qs)) + , m_networkInterfaceName(BITTORRENT_SESSION_KEY(u"InterfaceName"_qs)) + , m_networkInterfaceAddress(BITTORRENT_SESSION_KEY(u"InterfaceAddress"_qs)) + , m_encryption(BITTORRENT_SESSION_KEY(u"Encryption"_qs), 0) + , m_maxActiveCheckingTorrents(BITTORRENT_SESSION_KEY(u"MaxActiveCheckingTorrents"_qs), 1) + , m_isProxyPeerConnectionsEnabled(BITTORRENT_SESSION_KEY(u"ProxyPeerConnections"_qs), false) + , m_chokingAlgorithm(BITTORRENT_SESSION_KEY(u"ChokingAlgorithm"_qs), ChokingAlgorithm::FixedSlots , clampValue(ChokingAlgorithm::FixedSlots, ChokingAlgorithm::RateBased)) - , m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY("SeedChokingAlgorithm"), SeedChokingAlgorithm::FastestUpload + , m_seedChokingAlgorithm(BITTORRENT_SESSION_KEY(u"SeedChokingAlgorithm"_qs), SeedChokingAlgorithm::FastestUpload , clampValue(SeedChokingAlgorithm::RoundRobin, SeedChokingAlgorithm::AntiLeech)) - , m_storedTags(BITTORRENT_SESSION_KEY("Tags")) - , m_maxRatioAction(BITTORRENT_SESSION_KEY("MaxRatioAction"), Pause) - , m_savePath(BITTORRENT_SESSION_KEY("DefaultSavePath"), specialFolderLocation(SpecialFolder::Downloads)) - , m_downloadPath(BITTORRENT_SESSION_KEY("TempPath"), (savePath() / Path(u"temp"_qs))) - , m_isDownloadPathEnabled(BITTORRENT_SESSION_KEY("TempPathEnabled"), false) - , m_isSubcategoriesEnabled(BITTORRENT_SESSION_KEY("SubcategoriesEnabled"), false) - , m_useCategoryPathsInManualMode(BITTORRENT_SESSION_KEY("UseCategoryPathsInManualMode"), false) - , m_isAutoTMMDisabledByDefault(BITTORRENT_SESSION_KEY("DisableAutoTMMByDefault"), true) - , m_isDisableAutoTMMWhenCategoryChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/CategoryChanged"), false) - , m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/DefaultSavePathChanged"), true) - , m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY("DisableAutoTMMTriggers/CategorySavePathChanged"), true) - , m_isTrackerEnabled(BITTORRENT_KEY("TrackerEnabled"), false) - , m_peerTurnover(BITTORRENT_SESSION_KEY("PeerTurnover"), 4) - , m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY("PeerTurnoverCutOff"), 90) - , m_peerTurnoverInterval(BITTORRENT_SESSION_KEY("PeerTurnoverInterval"), 300) - , m_requestQueueSize(BITTORRENT_SESSION_KEY("RequestQueueSize"), 500) - , m_bannedIPs("State/BannedIPs" + , m_storedTags(BITTORRENT_SESSION_KEY(u"Tags"_qs)) + , m_maxRatioAction(BITTORRENT_SESSION_KEY(u"MaxRatioAction"_qs), Pause) + , m_savePath(BITTORRENT_SESSION_KEY(u"DefaultSavePath"_qs), specialFolderLocation(SpecialFolder::Downloads)) + , m_downloadPath(BITTORRENT_SESSION_KEY(u"TempPath"_qs), (savePath() / Path(u"temp"_qs))) + , m_isDownloadPathEnabled(BITTORRENT_SESSION_KEY(u"TempPathEnabled"_qs), false) + , m_isSubcategoriesEnabled(BITTORRENT_SESSION_KEY(u"SubcategoriesEnabled"_qs), false) + , m_useCategoryPathsInManualMode(BITTORRENT_SESSION_KEY(u"UseCategoryPathsInManualMode"_qs), false) + , m_isAutoTMMDisabledByDefault(BITTORRENT_SESSION_KEY(u"DisableAutoTMMByDefault"_qs), true) + , m_isDisableAutoTMMWhenCategoryChanged(BITTORRENT_SESSION_KEY(u"DisableAutoTMMTriggers/CategoryChanged"_qs), false) + , m_isDisableAutoTMMWhenDefaultSavePathChanged(BITTORRENT_SESSION_KEY(u"DisableAutoTMMTriggers/DefaultSavePathChanged"_qs), true) + , m_isDisableAutoTMMWhenCategorySavePathChanged(BITTORRENT_SESSION_KEY(u"DisableAutoTMMTriggers/CategorySavePathChanged"_qs), true) + , m_isTrackerEnabled(BITTORRENT_KEY(u"TrackerEnabled"_qs), false) + , m_peerTurnover(BITTORRENT_SESSION_KEY(u"PeerTurnover"_qs), 4) + , m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY(u"PeerTurnoverCutOff"_qs), 90) + , m_peerTurnoverInterval(BITTORRENT_SESSION_KEY(u"PeerTurnoverInterval"_qs), 300) + , m_requestQueueSize(BITTORRENT_SESSION_KEY(u"RequestQueueSize"_qs), 500) + , m_bannedIPs(u"State/BannedIPs"_qs , QStringList() , [](const QStringList &value) { @@ -482,9 +482,9 @@ Session::Session(QObject *parent) return tmp; } ) - , m_resumeDataStorageType(BITTORRENT_SESSION_KEY("ResumeDataStorageType"), ResumeDataStorageType::Legacy) + , m_resumeDataStorageType(BITTORRENT_SESSION_KEY(u"ResumeDataStorageType"_qs), ResumeDataStorageType::Legacy) #if defined(Q_OS_WIN) - , m_OSMemoryPriority(BITTORRENT_KEY("OSMemoryPriority"), OSMemoryPriority::BelowNormal) + , m_OSMemoryPriority(BITTORRENT_KEY(u"OSMemoryPriority"_qs), OSMemoryPriority::BelowNormal) #endif , m_seedingLimitTimer {new QTimer {this}} , m_resumeDataTimer {new QTimer {this}} @@ -4330,7 +4330,7 @@ void Session::storeCategories() const void Session::upgradeCategories() { - const auto legacyCategories = SettingValue("BitTorrent/Session/Categories").get(); + const auto legacyCategories = SettingValue(u"BitTorrent/Session/Categories"_qs).get(); for (auto it = legacyCategories.cbegin(); it != legacyCategories.cend(); ++it) { const QString categoryName = it.key(); diff --git a/src/base/net/proxyconfigurationmanager.cpp b/src/base/net/proxyconfigurationmanager.cpp index ccd35b947..915b3b554 100644 --- a/src/base/net/proxyconfigurationmanager.cpp +++ b/src/base/net/proxyconfigurationmanager.cpp @@ -28,7 +28,7 @@ #include "proxyconfigurationmanager.h" -#define SETTINGS_KEY(name) ("Network/Proxy/" name) +#define SETTINGS_KEY(name) (u"Network/Proxy/" name) bool Net::operator==(const ProxyConfiguration &left, const ProxyConfiguration &right) { @@ -50,12 +50,12 @@ ProxyConfigurationManager *ProxyConfigurationManager::m_instance = nullptr; ProxyConfigurationManager::ProxyConfigurationManager(QObject *parent) : QObject {parent} - , m_storeProxyOnlyForTorrents {SETTINGS_KEY("OnlyForTorrents")} - , m_storeProxyType {SETTINGS_KEY("Type")} - , m_storeProxyIP {SETTINGS_KEY("IP")} - , m_storeProxyPort {SETTINGS_KEY("Port")} - , m_storeProxyUsername {SETTINGS_KEY("Username")} - , m_storeProxyPassword {SETTINGS_KEY("Password")} + , m_storeProxyOnlyForTorrents {SETTINGS_KEY(u"OnlyForTorrents"_qs)} + , m_storeProxyType {SETTINGS_KEY(u"Type"_qs)} + , m_storeProxyIP {SETTINGS_KEY(u"IP"_qs)} + , m_storeProxyPort {SETTINGS_KEY(u"Port"_qs)} + , m_storeProxyUsername {SETTINGS_KEY(u"Username"_qs)} + , m_storeProxyPassword {SETTINGS_KEY(u"Password"_qs)} { m_config.type = m_storeProxyType.get(ProxyType::None); if ((m_config.type < ProxyType::None) || (m_config.type > ProxyType::SOCKS4)) diff --git a/src/base/path.cpp b/src/base/path.cpp index ce31ff3e8..d10658083 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "base/global.h" @@ -202,17 +203,12 @@ Path &Path::operator/=(const Path &other) return *this; } -Path &Path::operator+=(const QString &str) +Path &Path::operator+=(const QStringView str) { *this = *this + str; return *this; } -Path &Path::operator+=(const std::string &str) -{ - return (*this += QString::fromStdString(str)); -} - Path Path::commonPath(const Path &left, const Path &right) { if (left.isEmpty() || right.isEmpty()) @@ -305,19 +301,9 @@ Path operator/(const Path &lhs, const Path &rhs) return Path(lhs.m_pathStr + u'/' + rhs.m_pathStr); } -Path operator+(const Path &lhs, const QString &rhs) +Path operator+(const Path &lhs, const QStringView rhs) { - return Path(lhs.m_pathStr + rhs); -} - -Path operator+(const Path &lhs, const char rhs[]) -{ - return lhs + QString::fromLatin1(rhs); -} - -Path operator+(const Path &lhs, const std::string &rhs) -{ - return lhs + QString::fromStdString(rhs); + return Path(lhs.data() + rhs); } QDataStream &operator<<(QDataStream &out, const Path &path) diff --git a/src/base/path.h b/src/base/path.h index 24a3bb7d6..fe2172224 100644 --- a/src/base/path.h +++ b/src/base/path.h @@ -69,8 +69,7 @@ public: QString toString() const override; Path &operator/=(const Path &other); - Path &operator+=(const QString &str); - Path &operator+=(const std::string &str); + Path &operator+=(QStringView str); static Path commonPath(const Path &left, const Path &right); @@ -79,7 +78,6 @@ public: static void addRootFolder(PathList &filePaths, const Path &rootFolder); friend Path operator/(const Path &lhs, const Path &rhs); - friend Path operator+(const Path &lhs, const QString &rhs); private: // this constructor doesn't perform any checks @@ -93,8 +91,7 @@ Q_DECLARE_METATYPE(Path) bool operator==(const Path &lhs, const Path &rhs); bool operator!=(const Path &lhs, const Path &rhs); -Path operator+(const Path &lhs, const char rhs[]); -Path operator+(const Path &lhs, const std::string &rhs); +Path operator+(const Path &lhs, QStringView rhs); QDataStream &operator<<(QDataStream &out, const Path &path); QDataStream &operator>>(QDataStream &in, Path &path); diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp index d971aad81..36b1ec5f0 100644 --- a/src/base/rss/rss_autodownloader.cpp +++ b/src/base/rss/rss_autodownloader.cpp @@ -98,9 +98,9 @@ QString computeSmartFilterRegex(const QStringList &filters) } AutoDownloader::AutoDownloader() - : m_storeProcessingEnabled("RSS/AutoDownloader/EnableProcessing", false) - , m_storeSmartEpisodeFilter("RSS/AutoDownloader/SmartEpisodeFilter") - , m_storeDownloadRepacks("RSS/AutoDownloader/DownloadRepacks") + : m_storeProcessingEnabled(u"RSS/AutoDownloader/EnableProcessing"_qs, false) + , m_storeSmartEpisodeFilter(u"RSS/AutoDownloader/SmartEpisodeFilter"_qs) + , m_storeDownloadRepacks(u"RSS/AutoDownloader/DownloadRepacks"_qs) , m_processingTimer(new QTimer(this)) , m_ioThread(new QThread(this)) { diff --git a/src/base/rss/rss_session.cpp b/src/base/rss/rss_session.cpp index 5acbf302b..85d79f660 100644 --- a/src/base/rss/rss_session.cpp +++ b/src/base/rss/rss_session.cpp @@ -58,9 +58,9 @@ using namespace RSS; QPointer Session::m_instance = nullptr; Session::Session() - : m_storeProcessingEnabled("RSS/Session/EnableProcessing") - , m_storeRefreshInterval("RSS/Session/RefreshInterval", 30) - , m_storeMaxArticlesPerFeed("RSS/Session/MaxArticlesPerFeed", 50) + : m_storeProcessingEnabled(u"RSS/Session/EnableProcessing"_qs) + , m_storeRefreshInterval(u"RSS/Session/RefreshInterval"_qs, 30) + , m_storeMaxArticlesPerFeed(u"RSS/Session/MaxArticlesPerFeed"_qs, 50) , m_workingThread(new QThread(this)) { Q_ASSERT(!m_instance); // only one instance is allowed diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index 40ca7c5d7..b2c72de02 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -232,14 +232,14 @@ void SearchPluginManager::installPlugin_impl(const QString &name, const Path &pa const PluginInfo *plugin = pluginInfo(name); if (plugin && !(plugin->version < newVersion)) { - LogMsg(tr("Plugin already at version %1, which is greater than %2").arg(plugin->version, newVersion), Log::INFO); + LogMsg(tr("Plugin already at version %1, which is greater than %2").arg(plugin->version.toString(), newVersion.toString()), Log::INFO); emit pluginUpdateFailed(name, tr("A more recent version of this plugin is already installed.")); return; } // Process with install const Path destPath = pluginPath(name); - const Path backupPath = destPath + ".bak"; + const Path backupPath = destPath + u".bak"; bool updated = false; if (destPath.exists()) { @@ -536,7 +536,7 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info) ++numCorrectData; if (isUpdateNeeded(pluginName, version)) { - LogMsg(tr("Plugin \"%1\" is outdated, updating to version %2").arg(pluginName, version), Log::INFO); + LogMsg(tr("Plugin \"%1\" is outdated, updating to version %2").arg(pluginName, version.toString()), Log::INFO); updateInfo[pluginName] = version; } } diff --git a/src/base/settingvalue.h b/src/base/settingvalue.h index 7220612a7..9f9b7bbae 100644 --- a/src/base/settingvalue.h +++ b/src/base/settingvalue.h @@ -38,8 +38,8 @@ template class SettingValue { public: - explicit SettingValue(const char *keyName) - : m_keyName {QString::fromLatin1(keyName)} + explicit SettingValue(const QString &keyName) + : m_keyName {keyName} { } @@ -67,7 +67,7 @@ template class CachedSettingValue { public: - explicit CachedSettingValue(const char *keyName, const T &defaultValue = {}) + explicit CachedSettingValue(const QString &keyName, const T &defaultValue = {}) : m_setting {keyName} , m_cache {m_setting.get(defaultValue)} { @@ -76,7 +76,7 @@ public: // The signature of the ProxyFunc should be equivalent to the following: // T proxyFunc(const T &a); template - explicit CachedSettingValue(const char *keyName, const T &defaultValue, ProxyFunc &&proxyFunc) + explicit CachedSettingValue(const QString &keyName, const T &defaultValue, ProxyFunc &&proxyFunc) : m_setting {keyName} , m_cache {proxyFunc(m_setting.get(defaultValue))} { diff --git a/src/base/torrentfileguard.cpp b/src/base/torrentfileguard.cpp index 8bff9eee6..3ea4eb085 100644 --- a/src/base/torrentfileguard.cpp +++ b/src/base/torrentfileguard.cpp @@ -83,6 +83,6 @@ void TorrentFileGuard::setAutoDeleteMode(TorrentFileGuard::AutoDeleteMode mode) SettingValue &TorrentFileGuard::autoDeleteModeSetting() { - static SettingValue setting {"Core/AutoDeleteAddedTorrentFile"}; + static SettingValue setting {u"Core/AutoDeleteAddedTorrentFile"_qs}; return setting; } diff --git a/src/base/torrentfileswatcher.cpp b/src/base/torrentfileswatcher.cpp index 80fd8c7d5..de28a752d 100644 --- a/src/base/torrentfileswatcher.cpp +++ b/src/base/torrentfileswatcher.cpp @@ -604,7 +604,7 @@ void TorrentFilesWatcher::Worker::processFailedTorrents() if (value >= MAX_FAILED_RETRIES) { LogMsg(tr("Rejecting failed torrent file: %1").arg(torrentPath.toString())); - Utils::Fs::renameFile(torrentPath, (torrentPath + ".qbt_rejected")); + Utils::Fs::renameFile(torrentPath, (torrentPath + u".qbt_rejected")); return true; } diff --git a/src/base/utils/foreignapps.cpp b/src/base/utils/foreignapps.cpp index 13f96a7e1..2af79ca15 100644 --- a/src/base/utils/foreignapps.cpp +++ b/src/base/utils/foreignapps.cpp @@ -83,7 +83,7 @@ namespace } LogMsg(QCoreApplication::translate("Utils::ForeignApps", "Python detected, executable name: '%1', version: %2") - .arg(info.executableName, info.version), Log::INFO); + .arg(info.executableName, info.version.toString()), Log::INFO); return true; } diff --git a/src/base/utils/version.h b/src/base/utils/version.h index 9dd24cfe2..b9034c5a5 100644 --- a/src/base/utils/version.h +++ b/src/base/utils/version.h @@ -35,11 +35,12 @@ #include "base/exceptions.h" #include "base/global.h" +#include "base/interfaces/istringable.h" namespace Utils { template - class Version + class Version final : public IStringable { static_assert(N > 0, "The number of version components may not be smaller than 1"); static_assert(N >= Mandatory, @@ -108,7 +109,7 @@ namespace Utils return m_components.at(i); } - operator QString() const + QString toString() const override { // find the last one non-zero component std::size_t lastSignificantIndex = N - 1; diff --git a/src/gui/aboutdialog.cpp b/src/gui/aboutdialog.cpp index b5fc9be33..d592124bc 100644 --- a/src/gui/aboutdialog.cpp +++ b/src/gui/aboutdialog.cpp @@ -39,12 +39,12 @@ #include "uithememanager.h" #include "utils.h" -#define SETTINGS_KEY(name) "AboutDialog/" name +#define SETTINGS_KEY(name) u"AboutDialog/" name AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::AboutDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 536d9f395..41aab69fb 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -65,12 +65,12 @@ namespace { -#define SETTINGS_KEY(name) "AddNewTorrentDialog/" name - const QString KEY_ENABLED = QStringLiteral(SETTINGS_KEY("Enabled")); - const QString KEY_TOPLEVEL = QStringLiteral(SETTINGS_KEY("TopLevel")); - const QString KEY_SAVEPATHHISTORY = QStringLiteral(SETTINGS_KEY("SavePathHistory")); - const QString KEY_DOWNLOADPATHHISTORY = QStringLiteral(SETTINGS_KEY("DownloadPathHistory")); - const QString KEY_SAVEPATHHISTORYLENGTH = QStringLiteral(SETTINGS_KEY("SavePathHistoryLength")); +#define SETTINGS_KEY(name) u"AddNewTorrentDialog/" name + const QString KEY_ENABLED = SETTINGS_KEY(u"Enabled"_qs); + const QString KEY_TOPLEVEL = SETTINGS_KEY(u"TopLevel"_qs); + const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY(u"SavePathHistory"_qs); + const QString KEY_DOWNLOADPATHHISTORY = SETTINGS_KEY(u"DownloadPathHistory"_qs); + const QString KEY_SAVEPATHHISTORYLENGTH = SETTINGS_KEY(u"SavePathHistoryLength"_qs); // just a shortcut inline SettingsStorage *settings() @@ -170,15 +170,15 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP : QDialog(parent) , m_ui(new Ui::AddNewTorrentDialog) , m_torrentParams(inParams) - , m_storeDialogSize(SETTINGS_KEY("DialogSize")) - , m_storeDefaultCategory(SETTINGS_KEY("DefaultCategory")) - , m_storeRememberLastSavePath(SETTINGS_KEY("RememberLastSavePath")) + , m_storeDialogSize(SETTINGS_KEY(u"DialogSize"_qs)) + , m_storeDefaultCategory(SETTINGS_KEY(u"DefaultCategory"_qs)) + , m_storeRememberLastSavePath(SETTINGS_KEY(u"RememberLastSavePath"_qs)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - , m_storeTreeHeaderState("GUI/Qt6/" SETTINGS_KEY("TreeHeaderState")) - , m_storeSplitterState("GUI/Qt6/" SETTINGS_KEY("SplitterState")) + , m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"TreeHeaderState"_qs)) + , m_storeSplitterState(u"GUI/Qt6/" SETTINGS_KEY(u"SplitterState"_qs)) #else - , m_storeTreeHeaderState(SETTINGS_KEY("TreeHeaderState")) - , m_storeSplitterState(SETTINGS_KEY("SplitterState")) + , m_storeTreeHeaderState(SETTINGS_KEY(u"TreeHeaderState"_qs)) + , m_storeSplitterState(SETTINGS_KEY(u"SplitterState"_qs)) #endif { // TODO: set dialog file properties using m_torrentParams.filePriorities diff --git a/src/gui/banlistoptionsdialog.cpp b/src/gui/banlistoptionsdialog.cpp index f8078bd65..595a32836 100644 --- a/src/gui/banlistoptionsdialog.cpp +++ b/src/gui/banlistoptionsdialog.cpp @@ -38,12 +38,12 @@ #include "ui_banlistoptionsdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "BanListOptionsDialog/" name +#define SETTINGS_KEY(name) u"BanListOptionsDialog/" name BanListOptionsDialog::BanListOptionsDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::BanListOptionsDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_model(new QStringListModel(BitTorrent::Session::instance()->bannedIPs(), this)) { m_ui->setupUi(this); diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index e75a9f831..7a829613d 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -37,17 +37,17 @@ #include "uithememanager.h" #include "utils.h" -#define SETTINGS_KEY(name) "CookiesDialog/" name +#define SETTINGS_KEY(name) u"CookiesDialog/" name CookiesDialog::CookiesDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::CookiesDialog) , m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this)) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - , m_storeViewState("GUI/Qt6/" SETTINGS_KEY("ViewState")) + , m_storeViewState("GUI/Qt6/" SETTINGS_KEY(u"ViewState"_qs)) #else - , m_storeViewState(SETTINGS_KEY("CookiesViewState")) + , m_storeViewState(SETTINGS_KEY(u"CookiesViewState"_qs)) #endif { m_ui->setupUi(this); diff --git a/src/gui/downloadfromurldialog.cpp b/src/gui/downloadfromurldialog.cpp index cacce5f76..3a21cf514 100644 --- a/src/gui/downloadfromurldialog.cpp +++ b/src/gui/downloadfromurldialog.cpp @@ -39,7 +39,7 @@ #include "ui_downloadfromurldialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "DownloadFromURLDialog/" name +#define SETTINGS_KEY(name) u"DownloadFromURLDialog/" name namespace { @@ -61,7 +61,7 @@ namespace DownloadFromURLDialog::DownloadFromURLDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::DownloadFromURLDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/ipsubnetwhitelistoptionsdialog.cpp b/src/gui/ipsubnetwhitelistoptionsdialog.cpp index 4df2a0f0e..6be57b8a7 100644 --- a/src/gui/ipsubnetwhitelistoptionsdialog.cpp +++ b/src/gui/ipsubnetwhitelistoptionsdialog.cpp @@ -38,12 +38,12 @@ #include "ui_ipsubnetwhitelistoptionsdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "IPSubnetWhitelistOptionsDialog/" name +#define SETTINGS_KEY(name) u"IPSubnetWhitelistOptionsDialog/" name IPSubnetWhitelistOptionsDialog::IPSubnetWhitelistOptionsDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::IPSubnetWhitelistOptionsDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index fc7094389..18cd09ec0 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -104,9 +104,9 @@ using namespace std::chrono_literals; namespace { -#define SETTINGS_KEY(name) "GUI/" name -#define EXECUTIONLOG_SETTINGS_KEY(name) (SETTINGS_KEY("Log/") name) -#define NOTIFICATIONS_SETTINGS_KEY(name) (SETTINGS_KEY("Notifications/") name) +#define SETTINGS_KEY(name) u"GUI/" name +#define EXECUTIONLOG_SETTINGS_KEY(name) (SETTINGS_KEY(u"Log/"_qs) name) +#define NOTIFICATIONS_SETTINGS_KEY(name) (SETTINGS_KEY(u"Notifications/"_qs) name) const std::chrono::seconds PREVENT_SUSPEND_INTERVAL {60}; #if !defined(Q_OS_MACOS) @@ -125,13 +125,13 @@ namespace MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_ui(new Ui::MainWindow) - , m_storeExecutionLogEnabled(EXECUTIONLOG_SETTINGS_KEY("Enabled")) - , m_storeDownloadTrackerFavicon(SETTINGS_KEY("DownloadTrackerFavicon")) - , m_storeNotificationEnabled(NOTIFICATIONS_SETTINGS_KEY("Enabled")) - , m_storeNotificationTorrentAdded(NOTIFICATIONS_SETTINGS_KEY("TorrentAdded")) - , m_storeExecutionLogTypes(EXECUTIONLOG_SETTINGS_KEY("Types"), Log::MsgType::ALL) + , m_storeExecutionLogEnabled(EXECUTIONLOG_SETTINGS_KEY(u"Enabled"_qs)) + , m_storeDownloadTrackerFavicon(SETTINGS_KEY(u"DownloadTrackerFavicon"_qs)) + , m_storeNotificationEnabled(NOTIFICATIONS_SETTINGS_KEY(u"Enabled"_qs)) + , m_storeNotificationTorrentAdded(NOTIFICATIONS_SETTINGS_KEY(u"TorrentAdded"_qs)) + , m_storeExecutionLogTypes(EXECUTIONLOG_SETTINGS_KEY(u"Types"_qs), Log::MsgType::ALL) #if (defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) && defined(QT_DBUS_LIB) - , m_storeNotificationTimeOut(NOTIFICATIONS_SETTINGS_KEY("Timeout")) + , m_storeNotificationTimeOut(NOTIFICATIONS_SETTINGS_KEY(u"Timeout"_qs)) #endif { m_ui->setupUi(this); @@ -1892,14 +1892,14 @@ void MainWindow::on_actionSearchWidget_triggered() #ifdef Q_OS_WIN const QMessageBox::StandardButton buttonPressed = QMessageBox::question(this, tr("Old Python Runtime") , tr("Your Python version (%1) is outdated. Minimum requirement: %2.\nDo you want to install a newer version now?") - .arg(pyInfo.version, QLatin1String("3.5.0")) + .arg(pyInfo.version.toString(), u"3.5.0") , (QMessageBox::Yes | QMessageBox::No), QMessageBox::Yes); if (buttonPressed == QMessageBox::Yes) installPython(); #else QMessageBox::information(this, tr("Old Python Runtime") , tr("Your Python version (%1) is outdated. Please upgrade to latest version for search engines to work.\nMinimum requirement: %2.") - .arg(pyInfo.version, QLatin1String("3.5.0"))); + .arg(pyInfo.version.toString(), u"3.5.0")); #endif return; } @@ -2148,7 +2148,7 @@ void MainWindow::pythonDownloadFinished(const Net::DownloadResult &result) QProcess installer; qDebug("Launching Python installer in passive mode..."); - const Path exePath = result.filePath + ".exe"; + const Path exePath = result.filePath + u".exe"; Utils::Fs::renameFile(result.filePath, exePath); installer.start(exePath.toString(), {u"/passive"_qs}); diff --git a/src/gui/optionsdialog.cpp b/src/gui/optionsdialog.cpp index 1ff60726d..97c7082ea 100644 --- a/src/gui/optionsdialog.cpp +++ b/src/gui/optionsdialog.cpp @@ -71,7 +71,7 @@ #include "watchedfolderoptionsdialog.h" #include "watchedfoldersmodel.h" -#define SETTINGS_KEY(name) "OptionsDialog/" name +#define SETTINGS_KEY(name) u"OptionsDialog/" name namespace { @@ -179,9 +179,9 @@ private: OptionsDialog::OptionsDialog(QWidget *parent) : QDialog {parent} , m_ui {new Ui::OptionsDialog} - , m_storeDialogSize {SETTINGS_KEY("Size")} - , m_storeHSplitterSize {SETTINGS_KEY("HorizontalSplitterSizes")} - , m_storeLastViewedPage {SETTINGS_KEY("LastViewedPage")} + , m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)} + , m_storeHSplitterSize {SETTINGS_KEY(u"HorizontalSplitterSizes"_qs)} + , m_storeLastViewedPage {SETTINGS_KEY(u"LastViewedPage"_qs)} { qDebug("-> Constructing Options"); m_ui->setupUi(this); diff --git a/src/gui/previewselectdialog.cpp b/src/gui/previewselectdialog.cpp index 7329d870d..6c7427a09 100644 --- a/src/gui/previewselectdialog.cpp +++ b/src/gui/previewselectdialog.cpp @@ -46,17 +46,17 @@ #include "ui_previewselectdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "PreviewSelectDialog/" name +#define SETTINGS_KEY(name) u"PreviewSelectDialog/" name PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent) : QDialog(parent) , m_ui(new Ui::PreviewSelectDialog) , m_torrent(torrent) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) - , m_storeTreeHeaderState("GUI/Qt6/" SETTINGS_KEY("HeaderState")) + , m_storeTreeHeaderState(u"GUI/Qt6/" SETTINGS_KEY(u"HeaderState"_qs)) #else - , m_storeTreeHeaderState(SETTINGS_KEY("HeaderState")) + , m_storeTreeHeaderState(SETTINGS_KEY(u"HeaderState"_qs)) #endif { m_ui->setupUi(this); diff --git a/src/gui/search/pluginselectdialog.cpp b/src/gui/search/pluginselectdialog.cpp index 76031f93c..ca8b68862 100644 --- a/src/gui/search/pluginselectdialog.cpp +++ b/src/gui/search/pluginselectdialog.cpp @@ -48,7 +48,7 @@ #include "searchwidget.h" #include "ui_pluginselectdialog.h" -#define SETTINGS_KEY(name) "SearchPluginSelectDialog/" name +#define SETTINGS_KEY(name) u"SearchPluginSelectDialog/" name enum PluginColumns { @@ -62,7 +62,7 @@ enum PluginColumns PluginSelectDialog::PluginSelectDialog(SearchPluginManager *pluginManager, QWidget *parent) : QDialog(parent) , m_ui(new Ui::PluginSelectDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) , m_pluginManager(pluginManager) { m_ui->setupUi(this); @@ -315,7 +315,7 @@ void PluginSelectDialog::addNewPlugin(const QString &pluginName) DownloadRequest(plugin->url + u"/favicon.ico").saveToFile(true) , this, &PluginSelectDialog::iconDownloadFinished); } - item->setText(PLUGIN_VERSION, plugin->version); + item->setText(PLUGIN_VERSION, plugin->version.toString()); } void PluginSelectDialog::startAsyncOp() @@ -483,7 +483,7 @@ void PluginSelectDialog::pluginUpdated(const QString &name) finishAsyncOp(); PluginVersion version = m_pluginManager->pluginInfo(name)->version; QTreeWidgetItem *item = findItemWithID(name); - item->setText(PLUGIN_VERSION, version); + item->setText(PLUGIN_VERSION, version.toString()); m_updatedPlugins.append(name); finishPluginUpdate(); } diff --git a/src/gui/search/pluginsourcedialog.cpp b/src/gui/search/pluginsourcedialog.cpp index d65e6cf1f..c56cd0b3b 100644 --- a/src/gui/search/pluginsourcedialog.cpp +++ b/src/gui/search/pluginsourcedialog.cpp @@ -31,12 +31,12 @@ #include "gui/utils.h" #include "ui_pluginsourcedialog.h" -#define SETTINGS_KEY(name) "SearchPluginSourceDialog/" name +#define SETTINGS_KEY(name) u"SearchPluginSourceDialog/" name PluginSourceDialog::PluginSourceDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::PluginSourceDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/search/searchjobwidget.cpp b/src/gui/search/searchjobwidget.cpp index f75f879f5..8ef1551bf 100644 --- a/src/gui/search/searchjobwidget.cpp +++ b/src/gui/search/searchjobwidget.cpp @@ -547,7 +547,7 @@ void SearchJobWidget::appendSearchResults(const QVector &results) SettingValue &SearchJobWidget::nameFilteringModeSetting() { - static SettingValue setting {"Search/FilteringMode"}; + static SettingValue setting {u"Search/FilteringMode"_qs}; return setting; } diff --git a/src/gui/speedlimitdialog.cpp b/src/gui/speedlimitdialog.cpp index 62bbf095c..ea7b68809 100644 --- a/src/gui/speedlimitdialog.cpp +++ b/src/gui/speedlimitdialog.cpp @@ -37,7 +37,7 @@ #include "uithememanager.h" #include "utils.h" -#define SETTINGS_KEY(name) "SpeedLimitDialog/" name +#define SETTINGS_KEY(name) u"SpeedLimitDialog/" name namespace { @@ -52,7 +52,7 @@ namespace SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) : QDialog {parent} , m_ui {new Ui::SpeedLimitDialog} - , m_storeDialogSize {SETTINGS_KEY("Size")} + , m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)} { m_ui->setupUi(this); diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index 16532a54a..1e9fc12f1 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -40,12 +40,12 @@ #include "ui_statsdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "StatisticsDialog/" name +#define SETTINGS_KEY(name) u"StatisticsDialog/" name StatsDialog::StatsDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::StatsDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 6e4137b7c..d1b2213a5 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -42,29 +42,29 @@ #include "ui_torrentcreatordialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "TorrentCreator/" name +#define SETTINGS_KEY(name) u"TorrentCreator/" name TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultPath) : QDialog(parent) , m_ui(new Ui::TorrentCreatorDialog) , m_creatorThread(new BitTorrent::TorrentCreatorThread(this)) - , m_storeDialogSize(SETTINGS_KEY("Size")) - , m_storePieceSize(SETTINGS_KEY("PieceSize")) - , m_storePrivateTorrent(SETTINGS_KEY("PrivateTorrent")) - , m_storeStartSeeding(SETTINGS_KEY("StartSeeding")) - , m_storeIgnoreRatio(SETTINGS_KEY("IgnoreRatio")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) + , m_storePieceSize(SETTINGS_KEY(u"PieceSize"_qs)) + , m_storePrivateTorrent(SETTINGS_KEY(u"PrivateTorrent"_qs)) + , m_storeStartSeeding(SETTINGS_KEY(u"StartSeeding"_qs)) + , m_storeIgnoreRatio(SETTINGS_KEY(u"IgnoreRatio"_qs)) #ifdef QBT_USES_LIBTORRENT2 - , m_storeTorrentFormat(SETTINGS_KEY("TorrentFormat")) + , m_storeTorrentFormat(SETTINGS_KEY(u"TorrentFormat"_qs)) #else - , m_storeOptimizeAlignment(SETTINGS_KEY("OptimizeAlignment")) - , m_paddedFileSizeLimit(SETTINGS_KEY("PaddedFileSizeLimit")) + , m_storeOptimizeAlignment(SETTINGS_KEY(u"OptimizeAlignment"_qs)) + , m_paddedFileSizeLimit(SETTINGS_KEY(u"PaddedFileSizeLimit"_qs)) #endif - , m_storeLastAddPath(SETTINGS_KEY("LastAddPath")) - , m_storeTrackerList(SETTINGS_KEY("TrackerList")) - , m_storeWebSeedList(SETTINGS_KEY("WebSeedList")) - , m_storeComments(SETTINGS_KEY("Comments")) - , m_storeLastSavePath(SETTINGS_KEY("LastSavePath")) - , m_storeSource(SETTINGS_KEY("Source")) + , m_storeLastAddPath(SETTINGS_KEY(u"LastAddPath"_qs)) + , m_storeTrackerList(SETTINGS_KEY(u"TrackerList"_qs)) + , m_storeWebSeedList(SETTINGS_KEY(u"WebSeedList"_qs)) + , m_storeComments(SETTINGS_KEY(u"Comments"_qs)) + , m_storeLastSavePath(SETTINGS_KEY(u"LastSavePath"_qs)) + , m_storeSource(SETTINGS_KEY(u"Source"_qs)) { m_ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/gui/torrentoptionsdialog.cpp b/src/gui/torrentoptionsdialog.cpp index 3d13155e3..aee253172 100644 --- a/src/gui/torrentoptionsdialog.cpp +++ b/src/gui/torrentoptionsdialog.cpp @@ -45,7 +45,7 @@ #include "ui_torrentoptionsdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "TorrentOptionsDialog/" name +#define SETTINGS_KEY(name) u"TorrentOptionsDialog/" name namespace { @@ -62,7 +62,7 @@ namespace TorrentOptionsDialog::TorrentOptionsDialog(QWidget *parent, const QVector &torrents) : QDialog {parent} , m_ui {new Ui::TorrentOptionsDialog} - , m_storeDialogSize {SETTINGS_KEY("Size")} + , m_storeDialogSize {SETTINGS_KEY(u"Size"_qs)} , m_currentCategoriesString {QString::fromLatin1("--%1--").arg(tr("Currently used categories"))} { Q_ASSERT(!torrents.empty()); diff --git a/src/gui/trackerentriesdialog.cpp b/src/gui/trackerentriesdialog.cpp index 633919142..76ae8c965 100644 --- a/src/gui/trackerentriesdialog.cpp +++ b/src/gui/trackerentriesdialog.cpp @@ -37,12 +37,12 @@ #include "ui_trackerentriesdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "TrackerEntriesDialog/" name +#define SETTINGS_KEY(name) u"TrackerEntriesDialog/" name TrackerEntriesDialog::TrackerEntriesDialog(QWidget *parent) : QDialog(parent) , m_ui(new Ui::TrackerEntriesDialog) - , m_storeDialogSize(SETTINGS_KEY("Size")) + , m_storeDialogSize(SETTINGS_KEY(u"Size"_qs)) { m_ui->setupUi(this); diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 2f442d13a..b33912de1 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -93,8 +93,8 @@ namespace TransferListSortModel::TransferListSortModel(QObject *parent) : QSortFilterProxyModel {parent} - , m_subSortColumn {"TransferList/SubSortColumn", TransferListModel::TR_NAME, adjustSubSortColumn} - , m_subSortOrder {"TransferList/SubSortOrder", 0} + , m_subSortColumn {u"TransferList/SubSortColumn"_qs, TransferListModel::TR_NAME, adjustSubSortColumn} + , m_subSortOrder {u"TransferList/SubSortOrder"_qs, 0} { setSortRole(TransferListModel::UnderlyingDataRole); } diff --git a/src/gui/watchedfolderoptionsdialog.cpp b/src/gui/watchedfolderoptionsdialog.cpp index 9f89dfed0..2054f5efe 100644 --- a/src/gui/watchedfolderoptionsdialog.cpp +++ b/src/gui/watchedfolderoptionsdialog.cpp @@ -37,7 +37,7 @@ #include "ui_watchedfolderoptionsdialog.h" #include "utils.h" -#define SETTINGS_KEY(name) "WatchedFolderOptionsDialog/" name +#define SETTINGS_KEY(name) u"WatchedFolderOptionsDialog/" name WatchedFolderOptionsDialog::WatchedFolderOptionsDialog( const TorrentFilesWatcher::WatchedFolderOptions &watchedFolderOptions, QWidget *parent) @@ -45,7 +45,7 @@ WatchedFolderOptionsDialog::WatchedFolderOptionsDialog( , m_ui {new Ui::WatchedFolderOptionsDialog} , m_savePath {watchedFolderOptions.addTorrentParams.savePath} , m_downloadPath {watchedFolderOptions.addTorrentParams.downloadPath} - , m_storeDialogSize {SETTINGS_KEY("DialogSize")} + , m_storeDialogSize {SETTINGS_KEY(u"DialogSize"_qs)} { m_ui->setupUi(this); diff --git a/src/webui/api/appcontroller.cpp b/src/webui/api/appcontroller.cpp index 13112210b..fee2fea95 100644 --- a/src/webui/api/appcontroller.cpp +++ b/src/webui/api/appcontroller.cpp @@ -63,7 +63,7 @@ void AppController::webapiVersionAction() { - setResult(static_cast(API_VERSION)); + setResult(API_VERSION.toString()); } void AppController::versionAction() diff --git a/src/webui/api/searchcontroller.cpp b/src/webui/api/searchcontroller.cpp index 7f130ea3b..5e4c085f1 100644 --- a/src/webui/api/searchcontroller.cpp +++ b/src/webui/api/searchcontroller.cpp @@ -388,7 +388,7 @@ QJsonArray SearchController::getPluginsInfo(const QStringList &plugins) const pluginsArray << QJsonObject { {u"name"_qs, pluginInfo->name}, - {u"version"_qs, QString(pluginInfo->version)}, + {u"version"_qs, pluginInfo->version.toString()}, {u"fullName"_qs, pluginInfo->fullName}, {u"url"_qs, pluginInfo->url}, {u"supportedCategories"_qs, getPluginCategories(pluginInfo->supportedCategories)},