diff --git a/src/app/filelogger.cpp b/src/app/filelogger.cpp index 46a2afb93..120846807 100644 --- a/src/app/filelogger.cpp +++ b/src/app/filelogger.cpp @@ -78,7 +78,7 @@ void FileLogger::changePath(const Path &newPath) closeLogFile(); - m_path = newPath / Path("qbittorrent.log"); + m_path = newPath / Path(u"qbittorrent.log"_qs); m_logFile.setFileName(m_path.data()); Utils::Fs::mkpath(newPath); diff --git a/src/app/upgrade.cpp b/src/app/upgrade.cpp index 1a991839d..feb733380 100644 --- a/src/app/upgrade.cpp +++ b/src/app/upgrade.cpp @@ -31,6 +31,7 @@ #include #include "base/bittorrent/torrentcontentlayout.h" +#include "base/global.h" #include "base/logger.h" #include "base/net/proxyconfigurationmanager.h" #include "base/preferences.h" @@ -75,10 +76,10 @@ namespace const Path configPath = specialFolderLocation(SpecialFolder::Config); migrate(QLatin1String("Preferences/WebUI/HTTPS/Certificate") , QLatin1String("Preferences/WebUI/HTTPS/CertificatePath") - , (configPath / Path("WebUICertificate.crt"))); + , (configPath / Path(u"WebUICertificate.crt"_qs))); migrate(QLatin1String("Preferences/WebUI/HTTPS/Key") , QLatin1String("Preferences/WebUI/HTTPS/KeyPath") - , (configPath / Path("WebUIPrivateKey.pem"))); + , (configPath / Path(u"WebUIPrivateKey.pem"_qs))); } void upgradeTorrentContentLayout() diff --git a/src/base/bittorrent/bencoderesumedatastorage.cpp b/src/base/bittorrent/bencoderesumedatastorage.cpp index 6f3f5cb0d..eaefcbf5a 100644 --- a/src/base/bittorrent/bencoderesumedatastorage.cpp +++ b/src/base/bittorrent/bencoderesumedatastorage.cpp @@ -114,7 +114,7 @@ BitTorrent::BencodeResumeDataStorage::BencodeResumeDataStorage(const Path &path, m_registeredTorrents.append(TorrentID::fromString(rxMatch.captured(1))); } - loadQueue(m_resumeDataPath / Path("queue")); + loadQueue(m_resumeDataPath / Path(u"queue"_qs)); qDebug() << "Registered torrents count: " << m_registeredTorrents.size(); @@ -403,7 +403,7 @@ void BitTorrent::BencodeResumeDataStorage::Worker::storeQueue(const QVector result = Utils::IO::saveToFile(filepath, data); if (!result) { diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 2ec5dbf4c..735acf0b7 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -108,7 +108,7 @@ using namespace BitTorrent; -const Path CATEGORIES_FILE_NAME {"categories.json"}; +const Path CATEGORIES_FILE_NAME {u"categories.json"_qs}; namespace { @@ -457,7 +457,7 @@ Session::Session(QObject *parent) , 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("temp"))) + , 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) @@ -2556,7 +2556,7 @@ void Session::setSavePath(const Path &path) void Session::setDownloadPath(const Path &path) { - const Path newPath = (path.isAbsolute() ? path : (savePath() / Path("temp") / path)); + const Path newPath = (path.isAbsolute() ? path : (savePath() / Path(u"temp"_qs) / path)); if (newPath == m_downloadPath) return; @@ -4451,7 +4451,7 @@ void Session::startUpTorrents() { qDebug("Initializing torrents resume data storage..."); - const Path dbPath = specialFolderLocation(SpecialFolder::Data) / Path("torrents.db"); + const Path dbPath = specialFolderLocation(SpecialFolder::Data) / Path(u"torrents.db"_qs); const bool dbStorageExists = dbPath.exists(); ResumeDataStorage *startupStorage = nullptr; @@ -4461,13 +4461,13 @@ void Session::startUpTorrents() if (!dbStorageExists) { - const Path dataPath = specialFolderLocation(SpecialFolder::Data) / Path("BT_backup"); + const Path dataPath = specialFolderLocation(SpecialFolder::Data) / Path(u"BT_backup"_qs); startupStorage = new BencodeResumeDataStorage(dataPath, this); } } else { - const Path dataPath = specialFolderLocation(SpecialFolder::Data) / Path("BT_backup"); + const Path dataPath = specialFolderLocation(SpecialFolder::Data) / Path(u"BT_backup"_qs); m_resumeDataStorage = new BencodeResumeDataStorage(dataPath, this); if (dbStorageExists) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 030c87f21..3dda27e6b 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -324,8 +324,8 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession // Remove .unwanted directory if empty const Path newPath = spath / newRelPath; - qDebug() << "Attempting to remove \".unwanted\" folder at " << (newPath / Path(".unwanted")).toString(); - Utils::Fs::rmdir(newPath / Path(".unwanted")); + qDebug() << "Attempting to remove \".unwanted\" folder at " << (newPath / Path(u".unwanted"_qs)).toString(); + Utils::Fs::rmdir(newPath / Path(u".unwanted"_qs)); } } // == END UPGRADE CODE == diff --git a/src/base/global.h b/src/base/global.h index 8d5f38981..fdb251b94 100644 --- a/src/base/global.h +++ b/src/base/global.h @@ -35,7 +35,6 @@ #define QBT_APP_64BIT #endif -inline const char C_TORRENT_FILE_EXTENSION[] = ".torrent"; inline const int MAX_TORRENT_SIZE = 100 * 1024 * 1024; // 100 MiB template @@ -56,3 +55,5 @@ inline QString operator"" _qs(const char16_t *str, const std::size_t size) return QString::fromRawData(reinterpret_cast(str), static_cast(size)); } #endif + +inline const QString TORRENT_FILE_EXTENSION = u".torrent"_qs; diff --git a/src/base/http/requestparser.cpp b/src/base/http/requestparser.cpp index 254a583a7..996a9267d 100644 --- a/src/base/http/requestparser.cpp +++ b/src/base/http/requestparser.cpp @@ -323,7 +323,7 @@ bool RequestParser::parseFormData(const QByteArray &data) const QList headerLines = QStringView(headers).split(QString::fromLatin1(CRLF), Qt::SkipEmptyParts); for (const auto &line : headerLines) { - if (line.trimmed().startsWith(QString::fromLatin1(HEADER_CONTENT_DISPOSITION), Qt::CaseInsensitive)) + if (line.trimmed().startsWith(HEADER_CONTENT_DISPOSITION, Qt::CaseInsensitive)) { // extract out filename & name const QList directives = line.split(u';', Qt::SkipEmptyParts); diff --git a/src/base/http/types.h b/src/base/http/types.h index a63a601d0..27448bded 100644 --- a/src/base/http/types.h +++ b/src/base/http/types.h @@ -33,43 +33,45 @@ #include #include +#include "base/global.h" + namespace Http { - inline const char METHOD_GET[] = "GET"; - inline const char METHOD_POST[] = "POST"; - - inline const char HEADER_CACHE_CONTROL[] = "cache-control"; - inline const char HEADER_CONNECTION[] = "connection"; - inline const char HEADER_CONTENT_DISPOSITION[] = "content-disposition"; - inline const char HEADER_CONTENT_ENCODING[] = "content-encoding"; - inline const char HEADER_CONTENT_LENGTH[] = "content-length"; - inline const char HEADER_CONTENT_SECURITY_POLICY[] = "content-security-policy"; - inline const char HEADER_CONTENT_TYPE[] = "content-type"; - inline const char HEADER_DATE[] = "date"; - inline const char HEADER_HOST[] = "host"; - inline const char HEADER_ORIGIN[] = "origin"; - inline const char HEADER_REFERER[] = "referer"; - inline const char HEADER_REFERRER_POLICY[] = "referrer-policy"; - inline const char HEADER_SET_COOKIE[] = "set-cookie"; - inline const char HEADER_X_CONTENT_TYPE_OPTIONS[] = "x-content-type-options"; - inline const char HEADER_X_FORWARDED_FOR[] = "x-forwarded-for"; - inline const char HEADER_X_FORWARDED_HOST[] = "x-forwarded-host"; - inline const char HEADER_X_FRAME_OPTIONS[] = "x-frame-options"; - inline const char HEADER_X_XSS_PROTECTION[] = "x-xss-protection"; - - inline const char HEADER_REQUEST_METHOD_GET[] = "GET"; - inline const char HEADER_REQUEST_METHOD_HEAD[] = "HEAD"; - inline const char HEADER_REQUEST_METHOD_POST[] = "POST"; - - inline const char CONTENT_TYPE_HTML[] = "text/html"; - inline const char CONTENT_TYPE_CSS[] = "text/css"; - inline const char CONTENT_TYPE_TXT[] = "text/plain; charset=UTF-8"; - inline const char CONTENT_TYPE_JS[] = "application/javascript"; - inline const char CONTENT_TYPE_JSON[] = "application/json"; - inline const char CONTENT_TYPE_GIF[] = "image/gif"; - inline const char CONTENT_TYPE_PNG[] = "image/png"; - inline const char CONTENT_TYPE_FORM_ENCODED[] = "application/x-www-form-urlencoded"; - inline const char CONTENT_TYPE_FORM_DATA[] = "multipart/form-data"; + inline const QString METHOD_GET = u"GET"_qs; + inline const QString METHOD_POST = u"POST"_qs; + + inline const QString HEADER_CACHE_CONTROL = u"cache-control"_qs; + inline const QString HEADER_CONNECTION = u"connection"_qs; + inline const QString HEADER_CONTENT_DISPOSITION = u"content-disposition"_qs; + inline const QString HEADER_CONTENT_ENCODING = u"content-encoding"_qs; + inline const QString HEADER_CONTENT_LENGTH = u"content-length"_qs; + inline const QString HEADER_CONTENT_SECURITY_POLICY = u"content-security-policy"_qs; + inline const QString HEADER_CONTENT_TYPE = u"content-type"_qs; + inline const QString HEADER_DATE = u"date"_qs; + inline const QString HEADER_HOST = u"host"_qs; + inline const QString HEADER_ORIGIN = u"origin"_qs; + inline const QString HEADER_REFERER = u"referer"_qs; + inline const QString HEADER_REFERRER_POLICY = u"referrer-policy"_qs; + inline const QString HEADER_SET_COOKIE = u"set-cookie"_qs; + inline const QString HEADER_X_CONTENT_TYPE_OPTIONS = u"x-content-type-options"_qs; + inline const QString HEADER_X_FORWARDED_FOR = u"x-forwarded-for"_qs; + inline const QString HEADER_X_FORWARDED_HOST = u"x-forwarded-host"_qs; + inline const QString HEADER_X_FRAME_OPTIONS = u"x-frame-options"_qs; + inline const QString HEADER_X_XSS_PROTECTION = u"x-xss-protection"_qs; + + inline const QString HEADER_REQUEST_METHOD_GET = u"GET"_qs; + inline const QString HEADER_REQUEST_METHOD_HEAD = u"HEAD"_qs; + inline const QString HEADER_REQUEST_METHOD_POST = u"POST"_qs; + + inline const QString CONTENT_TYPE_HTML = u"text/html"_qs; + inline const QString CONTENT_TYPE_CSS = u"text/css"_qs; + inline const QString CONTENT_TYPE_TXT = u"text/plain; charset=UTF-8"_qs; + inline const QString CONTENT_TYPE_JS = u"application/javascript"_qs; + inline const QString CONTENT_TYPE_JSON = u"application/json"_qs; + inline const QString CONTENT_TYPE_GIF = u"image/gif"_qs; + inline const QString CONTENT_TYPE_PNG = u"image/png"_qs; + inline const QString CONTENT_TYPE_FORM_ENCODED = u"application/x-www-form-urlencoded"_qs; + inline const QString CONTENT_TYPE_FORM_DATA = u"multipart/form-data"_qs; // portability: "\r\n" doesn't guarantee mapping to the correct symbol inline const char CRLF[] = {0x0D, 0x0A, '\0'}; diff --git a/src/base/net/geoipmanager.cpp b/src/base/net/geoipmanager.cpp index 18ddd04f9..a9aae5944 100644 --- a/src/base/net/geoipmanager.cpp +++ b/src/base/net/geoipmanager.cpp @@ -33,6 +33,7 @@ #include #include +#include "base/global.h" #include "base/logger.h" #include "base/preferences.h" #include "base/profile.h" @@ -43,8 +44,8 @@ #include "geoipdatabase.h" const QString DATABASE_URL = QStringLiteral("https://download.db-ip.com/free/dbip-country-lite-%1.mmdb.gz"); -const char GEODB_FOLDER[] = "GeoDB"; -const char GEODB_FILENAME[] = "dbip-country-lite.mmdb"; +const QString GEODB_FOLDER = u"GeoDB"_qs; +const QString GEODB_FILENAME = u"dbip-country-lite.mmdb"_qs; using namespace Net; diff --git a/src/base/path.cpp b/src/base/path.cpp index 292163c98..02449d042 100644 --- a/src/base/path.cpp +++ b/src/base/path.cpp @@ -68,11 +68,6 @@ Path::Path(const std::string &pathStr) { } -Path::Path(const char pathStr[]) - : Path(QString::fromLatin1(pathStr)) -{ -} - bool Path::isValid() const { if (isEmpty()) @@ -211,11 +206,6 @@ Path &Path::operator+=(const QString &str) return *this; } -Path &Path::operator+=(const char str[]) -{ - return (*this += QString::fromLatin1(str)); -} - Path &Path::operator+=(const std::string &str) { return (*this += QString::fromStdString(str)); diff --git a/src/base/path.h b/src/base/path.h index 1abef4e02..614ba640f 100644 --- a/src/base/path.h +++ b/src/base/path.h @@ -40,7 +40,6 @@ public: Path() = default; explicit Path(const QString &pathStr); - explicit Path(const char pathStr[]); explicit Path(const std::string &pathStr); bool isValid() const; @@ -68,7 +67,6 @@ public: Path &operator/=(const Path &other); Path &operator+=(const QString &str); - Path &operator+=(const char str[]); Path &operator+=(const std::string &str); static Path commonPath(const Path &left, const Path &right); diff --git a/src/base/profile_p.cpp b/src/base/profile_p.cpp index 44dde0feb..7c0230409 100644 --- a/src/base/profile_p.cpp +++ b/src/base/profile_p.cpp @@ -31,6 +31,7 @@ #include +#include "base/global.h" #include "base/utils/fs.h" Private::Profile::Profile(const QString &configurationName) @@ -91,7 +92,7 @@ Path Private::DefaultProfile::dataLocation() const // On Linux keep using the legacy directory ~/.local/share/data/ if it exists const Path genericDataPath {QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)}; const Path profilePath {profileName()}; - const Path legacyDir = genericDataPath / Path("data") / profilePath; + const Path legacyDir = genericDataPath / Path(u"data"_qs) / profilePath; const Path dataDir = genericDataPath / profilePath; @@ -130,10 +131,10 @@ Private::CustomProfile::CustomProfile(const Path &rootPath, const QString &confi : Profile {configurationName} , m_rootPath {rootPath} , m_basePath {m_rootPath / Path(profileName())} - , m_cacheLocation {m_basePath / Path("cache")} - , m_configLocation {m_basePath / Path("config")} - , m_dataLocation {m_basePath / Path("data")} - , m_downloadLocation {m_basePath / Path("downloads")} + , m_cacheLocation {m_basePath / Path(u"cache"_qs)} + , m_configLocation {m_basePath / Path(u"config"_qs)} + , m_dataLocation {m_basePath / Path(u"data"_qs)} + , m_downloadLocation {m_basePath / Path(u"downloads"_qs)} { } diff --git a/src/base/search/searchdownloadhandler.cpp b/src/base/search/searchdownloadhandler.cpp index b20c64aa2..dbbee9bbd 100644 --- a/src/base/search/searchdownloadhandler.cpp +++ b/src/base/search/searchdownloadhandler.cpp @@ -30,6 +30,7 @@ #include +#include "base/global.h" #include "base/path.h" #include "base/utils/foreignapps.h" #include "base/utils/fs.h" @@ -45,7 +46,7 @@ SearchDownloadHandler::SearchDownloadHandler(const QString &siteUrl, const QStri , this, &SearchDownloadHandler::downloadProcessFinished); const QStringList params { - (m_manager->engineLocation() / Path("nova2dl.py")).toString(), + (m_manager->engineLocation() / Path(u"nova2dl.py"_qs)).toString(), siteUrl, url }; diff --git a/src/base/search/searchhandler.cpp b/src/base/search/searchhandler.cpp index d92c1752a..c685b4b7a 100644 --- a/src/base/search/searchhandler.cpp +++ b/src/base/search/searchhandler.cpp @@ -68,7 +68,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co const QStringList params { - (m_manager->engineLocation() / Path("nova2.py")).toString(), + (m_manager->engineLocation() / Path(u"nova2.py"_qs)).toString(), m_usedPlugins.join(','), m_category }; diff --git a/src/base/search/searchpluginmanager.cpp b/src/base/search/searchpluginmanager.cpp index de0701643..adea31d1e 100644 --- a/src/base/search/searchpluginmanager.cpp +++ b/src/base/search/searchpluginmanager.cpp @@ -363,7 +363,7 @@ QString SearchPluginManager::pluginFullName(const QString &pluginName) Path SearchPluginManager::pluginsLocation() { - return (engineLocation() / Path("engines")); + return (engineLocation() / Path(u"engines"_qs)); } Path SearchPluginManager::engineLocation() @@ -371,7 +371,7 @@ Path SearchPluginManager::engineLocation() static Path location; if (location.isEmpty()) { - location = specialFolderLocation(SpecialFolder::Data) / Path("nova3"); + location = specialFolderLocation(SpecialFolder::Data) / Path(u"nova3"_qs); Utils::Fs::mkpath(location); } @@ -416,20 +416,20 @@ void SearchPluginManager::updateNova() // create nova directory if necessary const Path enginePath = engineLocation(); - QFile packageFile {(enginePath / Path("__init__.py")).data()}; + QFile packageFile {(enginePath / Path(u"__init__.py"_qs)).data()}; packageFile.open(QIODevice::WriteOnly); packageFile.close(); - Utils::Fs::mkdir(enginePath / Path("engines")); + Utils::Fs::mkdir(enginePath / Path(u"engines"_qs)); - QFile packageFile2 {(enginePath / Path("engines/__init__.py")).data()}; + QFile packageFile2 {(enginePath / Path(u"engines/__init__.py"_qs)).data()}; packageFile2.open(QIODevice::WriteOnly); packageFile2.close(); // Copy search plugin files (if necessary) const auto updateFile = [&enginePath](const Path &filename, const bool compareVersion) { - const Path filePathBundled = Path(":/searchengine/nova3") / filename; + const Path filePathBundled = Path(u":/searchengine/nova3"_qs) / filename; const Path filePathDisk = enginePath / filename; if (compareVersion && (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk))) @@ -439,12 +439,12 @@ void SearchPluginManager::updateNova() Utils::Fs::copyFile(filePathBundled, filePathDisk); }; - updateFile(Path("helpers.py"), true); - updateFile(Path("nova2.py"), true); - updateFile(Path("nova2dl.py"), true); - updateFile(Path("novaprinter.py"), true); - updateFile(Path("sgmllib3.py"), false); - updateFile(Path("socks.py"), false); + updateFile(Path(u"helpers.py"_qs), true); + updateFile(Path(u"nova2.py"_qs), true); + updateFile(Path(u"nova2dl.py"_qs), true); + updateFile(Path(u"novaprinter.py"_qs), true); + updateFile(Path(u"sgmllib3.py"_qs), false); + updateFile(Path(u"socks.py"_qs), false); } void SearchPluginManager::update() @@ -452,7 +452,7 @@ void SearchPluginManager::update() QProcess nova; nova.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - const QStringList params {(engineLocation() / Path("/nova2.py")).toString(), QLatin1String("--capabilities")}; + const QStringList params {(engineLocation() / Path(u"/nova2.py"_qs)).toString(), QLatin1String("--capabilities")}; nova.start(Utils::ForeignApps::pythonInfo().executableName, params, QIODevice::ReadOnly); nova.waitForFinished(); diff --git a/src/base/utils/fs.cpp b/src/base/utils/fs.cpp index 7234d4232..ffb97bf07 100644 --- a/src/base/utils/fs.cpp +++ b/src/base/utils/fs.cpp @@ -207,7 +207,7 @@ qint64 Utils::Fs::freeDiskSpaceOnPath(const Path &path) Path Utils::Fs::tempPath() { - static const Path path = Path(QDir::tempPath()) / Path(".qBittorrent"); + static const Path path = Path(QDir::tempPath()) / Path(u".qBittorrent"_qs); mkdir(path); return path; } diff --git a/src/gui/aboutdialog.cpp b/src/gui/aboutdialog.cpp index c8f16e489..e0388f990 100644 --- a/src/gui/aboutdialog.cpp +++ b/src/gui/aboutdialog.cpp @@ -30,6 +30,7 @@ #include +#include "base/global.h" #include "base/path.h" #include "base/unicodestrings.h" #include "base/utils/misc.h" @@ -71,7 +72,7 @@ AboutDialog::AboutDialog(QWidget *parent) , tr("Bug Tracker:")); m_ui->labelAbout->setText(aboutText); - m_ui->labelMascot->setPixmap(Utils::Gui::scaledPixmap(Path(":/icons/mascot.png"), this)); + m_ui->labelMascot->setPixmap(Utils::Gui::scaledPixmap(Path(u":/icons/mascot.png"_qs), this)); // Thanks QFile thanksfile(":/thanks.html"); diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index ad03f89ab..57f270baa 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -567,23 +567,21 @@ void AddNewTorrentDialog::saveTorrentFile() { Q_ASSERT(hasMetadata()); - const QString torrentFileExtension {C_TORRENT_FILE_EXTENSION}; - const QString filter {tr("Torrent file (*%1)").arg(torrentFileExtension)}; + const QString filter {tr("Torrent file (*%1)").arg(TORRENT_FILE_EXTENSION)}; - QString path = QFileDialog::getSaveFileName( - this, tr("Save as torrent file") - , QDir::home().absoluteFilePath(m_torrentInfo.name() + torrentFileExtension) - , filter); + Path path {QFileDialog::getSaveFileName(this, tr("Save as torrent file") + , QDir::home().absoluteFilePath(m_torrentInfo.name() + TORRENT_FILE_EXTENSION) + , filter)}; if (path.isEmpty()) return; - if (!path.endsWith(torrentFileExtension, Qt::CaseInsensitive)) - path += torrentFileExtension; + if (!path.hasExtension(TORRENT_FILE_EXTENSION)) + path += TORRENT_FILE_EXTENSION; - const nonstd::expected result = m_torrentInfo.saveToFile(Path(path)); + const nonstd::expected result = m_torrentInfo.saveToFile(path); if (!result) { QMessageBox::critical(this, tr("I/O Error") - , tr("Couldn't export torrent metadata file '%1'. Reason: %2.").arg(path, result.error())); + , tr("Couldn't export torrent metadata file '%1'. Reason: %2.").arg(path.toString(), result.error())); } } diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index b96575aa1..f29a7ef68 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -116,7 +116,7 @@ namespace bool isTorrentLink(const QString &str) { return str.startsWith(QLatin1String("magnet:"), Qt::CaseInsensitive) - || str.endsWith(QLatin1String(C_TORRENT_FILE_EXTENSION), Qt::CaseInsensitive) + || str.endsWith(TORRENT_FILE_EXTENSION, Qt::CaseInsensitive) || (!str.startsWith(QLatin1String("file:"), Qt::CaseInsensitive) && Net::DownloadManager::hasSupportedScheme(str)); } @@ -1421,7 +1421,7 @@ void MainWindow::on_actionOpen_triggered() // Note: it is possible to select more than one file const QStringList pathsList = QFileDialog::getOpenFileNames(this, tr("Open Torrent Files"), pref->getMainLastDir().data(), - tr("Torrent Files") + " (*" + C_TORRENT_FILE_EXTENSION + ')'); + tr("Torrent Files") + u" (*" + TORRENT_FILE_EXTENSION + u')'); if (pathsList.isEmpty()) return; diff --git a/src/gui/rss/htmlbrowser.cpp b/src/gui/rss/htmlbrowser.cpp index 4bbd71cfd..6bd4c49cb 100644 --- a/src/gui/rss/htmlbrowser.cpp +++ b/src/gui/rss/htmlbrowser.cpp @@ -37,6 +37,7 @@ #include #include +#include "base/global.h" #include "base/path.h" #include "base/profile.h" @@ -45,7 +46,7 @@ HtmlBrowser::HtmlBrowser(QWidget *parent) { m_netManager = new QNetworkAccessManager(this); m_diskCache = new QNetworkDiskCache(this); - m_diskCache->setCacheDirectory((specialFolderLocation(SpecialFolder::Cache) / Path("rss")).data()); + m_diskCache->setCacheDirectory((specialFolderLocation(SpecialFolder::Cache) / Path(u"rss"_qs)).data()); m_diskCache->setMaximumCacheSize(50 * 1024 * 1024); qDebug() << "HtmlBrowser cache path:" << m_diskCache->cacheDirectory() << " max size:" << m_diskCache->maximumCacheSize() / 1024 / 1024 << "MB"; m_netManager->setCache(m_diskCache); diff --git a/src/gui/torrentcreatordialog.cpp b/src/gui/torrentcreatordialog.cpp index 491539808..6af508b41 100644 --- a/src/gui/torrentcreatordialog.cpp +++ b/src/gui/torrentcreatordialog.cpp @@ -188,8 +188,8 @@ void TorrentCreatorDialog::onCreateButtonClicked() Path destPath {QFileDialog::getSaveFileName(this, tr("Select where to save the new torrent"), savePath.data(), tr("Torrent Files (*.torrent)"))}; if (destPath.isEmpty()) return; - if (!destPath.hasExtension(C_TORRENT_FILE_EXTENSION)) - destPath += C_TORRENT_FILE_EXTENSION; + if (!destPath.hasExtension(TORRENT_FILE_EXTENSION)) + destPath += TORRENT_FILE_EXTENSION; m_storeLastSavePath = destPath.parentPath(); // Disable dialog & set busy cursor diff --git a/src/gui/uithememanager.cpp b/src/gui/uithememanager.cpp index 4f033b63f..5dea4e9ac 100644 --- a/src/gui/uithememanager.cpp +++ b/src/gui/uithememanager.cpp @@ -37,6 +37,7 @@ #include #include +#include "base/global.h" #include "base/logger.h" #include "base/path.h" #include "base/preferences.h" @@ -44,7 +45,7 @@ namespace { - const Path DEFAULT_ICONS_DIR {":icons"}; + const Path DEFAULT_ICONS_DIR {u":icons"_qs}; const QString CONFIG_FILE_NAME {QStringLiteral("config.json")}; const QString STYLESHEET_FILE_NAME {QStringLiteral("stylesheet.qss")}; @@ -53,7 +54,7 @@ namespace // point to a file `file.svg` in root directory of CONFIG_FILE_NAME const QString STYLESHEET_RESOURCES_DIR {QStringLiteral(":/uitheme")}; - const Path THEME_ICONS_DIR {"icons"}; + const Path THEME_ICONS_DIR {u"icons"_qs}; Path findIcon(const QString &iconId, const Path &dir) { @@ -101,7 +102,7 @@ namespace } private: - const Path m_qrcThemeDir {":/uitheme"}; + const Path m_qrcThemeDir {u":/uitheme"_qs}; const Path m_qrcIconsDir = m_qrcThemeDir / THEME_ICONS_DIR; }; diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 55e78ec44..9596412a0 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -152,7 +152,7 @@ void WebApplication::sendWebUIFile() if (request().path.startsWith(PATH_PREFIX_ICONS)) { const Path imageFilename {request().path.mid(PATH_PREFIX_ICONS.size())}; - sendFile(Path(":/icons") / imageFilename); + sendFile(Path(u":/icons"_qs) / imageFilename); return; } } @@ -332,7 +332,7 @@ void WebApplication::configure() m_currentLocale = newLocale; m_translatedFiles.clear(); - m_translationFileLoaded = m_translator.load((m_rootFolder / Path("translations/webui_") + newLocale).data()); + m_translationFileLoaded = m_translator.load((m_rootFolder / Path(u"translations/webui_"_qs) + newLocale).data()); if (m_translationFileLoaded) { LogMsg(tr("Web UI translation for selected locale (%1) has been successfully loaded.") @@ -358,15 +358,15 @@ void WebApplication::configure() m_isHttpsEnabled = pref->isWebUiHttpsEnabled(); m_prebuiltHeaders.clear(); - m_prebuiltHeaders.push_back({QLatin1String(Http::HEADER_X_XSS_PROTECTION), QLatin1String("1; mode=block")}); - m_prebuiltHeaders.push_back({QLatin1String(Http::HEADER_X_CONTENT_TYPE_OPTIONS), QLatin1String("nosniff")}); + m_prebuiltHeaders.push_back({Http::HEADER_X_XSS_PROTECTION, QLatin1String("1; mode=block")}); + m_prebuiltHeaders.push_back({Http::HEADER_X_CONTENT_TYPE_OPTIONS, QLatin1String("nosniff")}); if (!m_isAltUIUsed) - m_prebuiltHeaders.push_back({QLatin1String(Http::HEADER_REFERRER_POLICY), QLatin1String("same-origin")}); + m_prebuiltHeaders.push_back({Http::HEADER_REFERRER_POLICY, QLatin1String("same-origin")}); const bool isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled(); if (isClickjackingProtectionEnabled) - m_prebuiltHeaders.push_back({QLatin1String(Http::HEADER_X_FRAME_OPTIONS), QLatin1String("SAMEORIGIN")}); + m_prebuiltHeaders.push_back({Http::HEADER_X_FRAME_OPTIONS, QLatin1String("SAMEORIGIN")}); const QString contentSecurityPolicy = (m_isAltUIUsed @@ -375,7 +375,7 @@ void WebApplication::configure() + (isClickjackingProtectionEnabled ? QLatin1String(" frame-ancestors 'self';") : QLatin1String("")) + (m_isHttpsEnabled ? QLatin1String(" upgrade-insecure-requests;") : QLatin1String("")); if (!contentSecurityPolicy.isEmpty()) - m_prebuiltHeaders.push_back({QLatin1String(Http::HEADER_CONTENT_SECURITY_POLICY), contentSecurityPolicy}); + m_prebuiltHeaders.push_back({Http::HEADER_CONTENT_SECURITY_POLICY, contentSecurityPolicy}); if (pref->isWebUICustomHTTPHeadersEnabled()) {