mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Use QString literals
The plan is to define `QT_NO_CAST_FROM_ASCII` eventually. PR #16561.
This commit is contained in:
parent
2c8447853b
commit
ab64ee872b
@ -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);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <QMetaEnum>
|
||||
|
||||
#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()
|
||||
|
@ -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<Torr
|
||||
for (const BitTorrent::TorrentID &torrentID : queue)
|
||||
data += (torrentID.toString().toLatin1() + '\n');
|
||||
|
||||
const Path filepath = m_resumeDataDir / Path("queue");
|
||||
const Path filepath = m_resumeDataDir / Path(u"queue"_qs);
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(filepath, data);
|
||||
if (!result)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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 ==
|
||||
|
@ -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 <typename T>
|
||||
@ -56,3 +55,5 @@ inline QString operator"" _qs(const char16_t *str, const std::size_t size)
|
||||
return QString::fromRawData(reinterpret_cast<const QChar *>(str), static_cast<int>(size));
|
||||
}
|
||||
#endif
|
||||
|
||||
inline const QString TORRENT_FILE_EXTENSION = u".torrent"_qs;
|
||||
|
@ -323,7 +323,7 @@ bool RequestParser::parseFormData(const QByteArray &data)
|
||||
const QList<QStringView> 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<QStringView> directives = line.split(u';', Qt::SkipEmptyParts);
|
||||
|
@ -33,43 +33,45 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "base/global.h"
|
||||
|
||||
namespace Http
|
||||
{
|
||||
inline const char METHOD_GET[] = "GET";
|
||||
inline const char METHOD_POST[] = "POST";
|
||||
inline const QString METHOD_GET = u"GET"_qs;
|
||||
inline const QString METHOD_POST = u"POST"_qs;
|
||||
|
||||
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 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 char HEADER_REQUEST_METHOD_GET[] = "GET";
|
||||
inline const char HEADER_REQUEST_METHOD_HEAD[] = "HEAD";
|
||||
inline const char HEADER_REQUEST_METHOD_POST[] = "POST";
|
||||
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 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 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'};
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <QHostAddress>
|
||||
#include <QLocale>
|
||||
|
||||
#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;
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#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)}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
#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
|
||||
};
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#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");
|
||||
|
@ -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<void, QString> result = m_torrentInfo.saveToFile(Path(path));
|
||||
const nonstd::expected<void, QString> 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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <QScrollBar>
|
||||
#include <QStyle>
|
||||
|
||||
#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);
|
||||
|
@ -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
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <QPalette>
|
||||
#include <QResource>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
||||
|
@ -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())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user