Port to QStringLiteral operator
This commit is contained in:
@@ -37,6 +37,8 @@
|
||||
#include "cddalister.h"
|
||||
#include "core/logging.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
QStringList CddaLister::DeviceUniqueIDs() { return devices_list_; }
|
||||
|
||||
QVariantList CddaLister::DeviceIcons(const QString &id) {
|
||||
@@ -44,7 +46,7 @@ QVariantList CddaLister::DeviceIcons(const QString &id) {
|
||||
Q_UNUSED(id)
|
||||
|
||||
QVariantList icons;
|
||||
icons << QStringLiteral("media-optical");
|
||||
icons << u"media-optical"_s;
|
||||
return icons;
|
||||
|
||||
}
|
||||
@@ -105,12 +107,12 @@ QString CddaLister::MakeFriendlyName(const QString &id) {
|
||||
return QString::fromUtf8(cd_info.psz_model);
|
||||
}
|
||||
cdio_destroy(cdio);
|
||||
return QStringLiteral("CD (") + id + QLatin1Char(')');
|
||||
return u"CD ("_s + id + QLatin1Char(')');
|
||||
|
||||
}
|
||||
|
||||
QList<QUrl> CddaLister::MakeDeviceUrls(const QString &id) {
|
||||
return QList<QUrl>() << QUrl(QStringLiteral("cdda://") + id);
|
||||
return QList<QUrl>() << QUrl(u"cdda://"_s + id);
|
||||
}
|
||||
|
||||
void CddaLister::UnmountDevice(const QString &id) {
|
||||
@@ -142,7 +144,7 @@ bool CddaLister::Init() {
|
||||
}
|
||||
#ifdef Q_OS_MACOS
|
||||
// Every track is detected as a separate device on Darwin. The raw disk looks like /dev/rdisk1
|
||||
if (!device.contains(QRegularExpression(QStringLiteral("^/dev/rdisk[0-9]$")))) {
|
||||
if (!device.contains(QRegularExpression(u"^/dev/rdisk[0-9]$"_s))) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
CddaSongLoader::CddaSongLoader(const QUrl &url, QObject *parent)
|
||||
: QObject(parent),
|
||||
url_(url),
|
||||
@@ -73,7 +75,7 @@ void CddaSongLoader::LoadSongs() {
|
||||
QMutexLocker locker(&mutex_load_);
|
||||
cdio_ = cdio_open(url_.path().toLocal8Bit().constData(), DRIVER_DEVICE);
|
||||
if (cdio_ == nullptr) {
|
||||
Error(QStringLiteral("Unable to open CDIO device."));
|
||||
Error(u"Unable to open CDIO device."_s);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ DeviceDatabaseBackend::DeviceList DeviceDatabaseBackend::GetAllDevices() {
|
||||
QMutexLocker l(db_->Mutex());
|
||||
QSqlDatabase db(db_->Connect());
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("SELECT ROWID, unique_id, friendly_name, size, icon, schema_version, transcode_mode, transcode_format FROM devices"));
|
||||
q.prepare(u"SELECT ROWID, unique_id, friendly_name, size, icon, schema_version, transcode_mode, transcode_format FROM devices"_s);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return ret;
|
||||
@@ -132,13 +132,13 @@ int DeviceDatabaseBackend::AddDevice(const Device &device) {
|
||||
|
||||
// Insert the device into the devices table
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("INSERT INTO devices (unique_id, friendly_name, size, icon, transcode_mode, transcode_format) VALUES (:unique_id, :friendly_name, :size, :icon, :transcode_mode, :transcode_format)"));
|
||||
q.BindValue(QStringLiteral(":unique_id"), device.unique_id_);
|
||||
q.BindValue(QStringLiteral(":friendly_name"), device.friendly_name_);
|
||||
q.BindValue(QStringLiteral(":size"), device.size_);
|
||||
q.BindValue(QStringLiteral(":icon"), device.icon_name_);
|
||||
q.BindValue(QStringLiteral(":transcode_mode"), static_cast<int>(device.transcode_mode_));
|
||||
q.BindValue(QStringLiteral(":transcode_format"), static_cast<int>(device.transcode_format_));
|
||||
q.prepare(u"INSERT INTO devices (unique_id, friendly_name, size, icon, transcode_mode, transcode_format) VALUES (:unique_id, :friendly_name, :size, :icon, :transcode_mode, :transcode_format)"_s);
|
||||
q.BindValue(u":unique_id"_s, device.unique_id_);
|
||||
q.BindValue(u":friendly_name"_s, device.friendly_name_);
|
||||
q.BindValue(u":size"_s, device.size_);
|
||||
q.BindValue(u":icon"_s, device.icon_name_);
|
||||
q.BindValue(u":transcode_mode"_s, static_cast<int>(device.transcode_mode_));
|
||||
q.BindValue(u":transcode_format"_s, static_cast<int>(device.transcode_format_));
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return -1;
|
||||
@@ -172,8 +172,8 @@ void DeviceDatabaseBackend::RemoveDevice(const int id) {
|
||||
// Remove the device from the devices table
|
||||
{
|
||||
SqlQuery q(db);
|
||||
q.prepare(QStringLiteral("DELETE FROM devices WHERE ROWID=:id"));
|
||||
q.BindValue(QStringLiteral(":id"), id);
|
||||
q.prepare(u"DELETE FROM devices WHERE ROWID=:id"_s);
|
||||
q.BindValue(u":id"_s, id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
return;
|
||||
@@ -234,11 +234,11 @@ void DeviceDatabaseBackend::SetDeviceOptions(const int id, const QString &friend
|
||||
" transcode_mode=:transcode_mode,"
|
||||
" transcode_format=:transcode_format"
|
||||
" WHERE ROWID=:id"));
|
||||
q.BindValue(QStringLiteral(":friendly_name"), friendly_name);
|
||||
q.BindValue(QStringLiteral(":icon_name"), icon_name);
|
||||
q.BindValue(QStringLiteral(":transcode_mode"), static_cast<int>(mode));
|
||||
q.BindValue(QStringLiteral(":transcode_format"), static_cast<int>(format));
|
||||
q.BindValue(QStringLiteral(":id"), id);
|
||||
q.BindValue(u":friendly_name"_s, friendly_name);
|
||||
q.BindValue(u":icon_name"_s, icon_name);
|
||||
q.BindValue(u":transcode_mode"_s, static_cast<int>(mode));
|
||||
q.BindValue(u":transcode_format"_s, static_cast<int>(format));
|
||||
q.BindValue(u":id"_s, id);
|
||||
if (!q.Exec()) {
|
||||
db_->ReportErrors(q);
|
||||
}
|
||||
|
||||
@@ -115,48 +115,48 @@ QString GetIpodColour(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_MINI_GREEN:
|
||||
case ITDB_IPOD_MODEL_NANO_GREEN:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_GREEN:
|
||||
return QStringLiteral("green");
|
||||
return u"green"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_BLUE:
|
||||
case ITDB_IPOD_MODEL_NANO_BLUE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_BLUE:
|
||||
return QStringLiteral("blue");
|
||||
return u"blue"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_PINK:
|
||||
case ITDB_IPOD_MODEL_NANO_PINK:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_PINK:
|
||||
return QStringLiteral("pink");
|
||||
return u"pink"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_MINI_GOLD:
|
||||
return QStringLiteral("gold");
|
||||
return u"gold"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_WHITE:
|
||||
case ITDB_IPOD_MODEL_VIDEO_WHITE:
|
||||
return QStringLiteral("white");
|
||||
return u"white"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_SILVER:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_SILVER:
|
||||
return QStringLiteral("silver");
|
||||
return u"silver"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_RED:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_RED:
|
||||
return QStringLiteral("red");
|
||||
return u"red"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_YELLOW:
|
||||
return QStringLiteral("yellow");
|
||||
return u"yellow"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_PURPLE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_PURPLE:
|
||||
return QStringLiteral("purple");
|
||||
return u"purple"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_ORANGE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_ORANGE:
|
||||
return QStringLiteral("orange");
|
||||
return u"orange"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_BLACK:
|
||||
case ITDB_IPOD_MODEL_VIDEO_BLACK:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_BLACK:
|
||||
return QStringLiteral("black");
|
||||
return u"black"_s;
|
||||
|
||||
default:
|
||||
return QString();
|
||||
@@ -172,7 +172,7 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_MINI_PINK:
|
||||
case ITDB_IPOD_MODEL_MINI_GREEN:
|
||||
case ITDB_IPOD_MODEL_MINI_GOLD:
|
||||
return QStringLiteral("mini");
|
||||
return u"mini"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_NANO_WHITE:
|
||||
case ITDB_IPOD_MODEL_NANO_BLACK:
|
||||
@@ -184,7 +184,7 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_NANO_YELLOW:
|
||||
case ITDB_IPOD_MODEL_NANO_PURPLE:
|
||||
case ITDB_IPOD_MODEL_NANO_ORANGE:
|
||||
return QStringLiteral("nano");
|
||||
return u"nano"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_SHUFFLE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_SILVER:
|
||||
@@ -193,17 +193,17 @@ QString GetIpodModel(Itdb_IpodModel model) {
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_GREEN:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_ORANGE:
|
||||
case ITDB_IPOD_MODEL_SHUFFLE_RED:
|
||||
return QStringLiteral("shuffle");
|
||||
return u"shuffle"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_COLOR:
|
||||
case ITDB_IPOD_MODEL_REGULAR:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_SILVER:
|
||||
case ITDB_IPOD_MODEL_CLASSIC_BLACK:
|
||||
return QStringLiteral("standard");
|
||||
return u"standard"_s;
|
||||
|
||||
case ITDB_IPOD_MODEL_COLOR_U2:
|
||||
case ITDB_IPOD_MODEL_REGULAR_U2:
|
||||
return QStringLiteral("U2");
|
||||
return u"U2"_s;
|
||||
|
||||
default:
|
||||
return QString();
|
||||
@@ -218,7 +218,7 @@ QUrl DeviceLister::MakeUrlFromLocalPath(const QString &path) const {
|
||||
|
||||
if (IsIpod(path)) {
|
||||
QUrl ret;
|
||||
ret.setScheme(QStringLiteral("ipod"));
|
||||
ret.setScheme(u"ipod"_s);
|
||||
ret.setPath(QDir::fromNativeSeparators(path));
|
||||
return ret;
|
||||
}
|
||||
@@ -244,7 +244,7 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
const Itdb_IpodInfo *info = itdb_device_get_ipod_info(device);
|
||||
|
||||
if (info->ipod_model == ITDB_IPOD_MODEL_INVALID) {
|
||||
ret << QStringLiteral("device-ipod");
|
||||
ret << u"device-ipod"_s;
|
||||
}
|
||||
else {
|
||||
QString model = GetIpodModel(info->ipod_model);
|
||||
@@ -260,7 +260,7 @@ QVariantList DeviceLister::GuessIconForPath(const QString &path) {
|
||||
}
|
||||
|
||||
if (ret.isEmpty()) {
|
||||
ret << QStringLiteral("device-ipod");
|
||||
ret << u"device-ipod"_s;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -280,7 +280,7 @@ QVariantList DeviceLister::GuessIconForModel(const QString &vendor, const QStrin
|
||||
|
||||
QVariantList ret;
|
||||
if (vendor.startsWith("Google"_L1) && model.contains("Nexus"_L1)) {
|
||||
ret << QStringLiteral("phone-google-nexus-one");
|
||||
ret << u"phone-google-nexus-one"_s;
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ const int DeviceManager::kDeviceIconOverlaySize = 16;
|
||||
DeviceManager::DeviceManager(Application *app, QObject *parent)
|
||||
: SimpleTreeModel<DeviceInfo>(new DeviceInfo(this), parent),
|
||||
app_(app),
|
||||
not_connected_overlay_(IconLoader::Load(QStringLiteral("edit-delete"))) {
|
||||
not_connected_overlay_(IconLoader::Load(u"edit-delete"_s)) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
||||
@@ -604,7 +604,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
// If it was "ipod" or "mtp" then the user compiled out support and the device won't work properly.
|
||||
if (url.scheme() == "mtp"_L1 || url.scheme() == "gphoto2"_L1) {
|
||||
if (QMessageBox::critical(nullptr, tr("This device will not work properly"),
|
||||
tr("This is an MTP device, but you compiled Strawberry without libmtp support.") + QStringLiteral(" ") +
|
||||
tr("This is an MTP device, but you compiled Strawberry without libmtp support.") + u" "_s +
|
||||
tr("If you continue, this device will work slowly and songs copied to it may not work."),
|
||||
QMessageBox::Abort, QMessageBox::Ignore) == QMessageBox::Abort)
|
||||
return ret;
|
||||
|
||||
@@ -57,6 +57,8 @@
|
||||
#include "transcoder/transcoder.h"
|
||||
#include "ui_deviceproperties.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
DeviceProperties::DeviceProperties(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_DeviceProperties),
|
||||
@@ -87,13 +89,13 @@ void DeviceProperties::ShowDevice(const QModelIndex &idx) {
|
||||
|
||||
if (ui_->icon->count() == 0) {
|
||||
// Only load the icons the first time the dialog is shown
|
||||
const QStringList icon_names = QStringList() << QStringLiteral("device")
|
||||
<< QStringLiteral("device-usb-drive")
|
||||
<< QStringLiteral("device-usb-flash")
|
||||
<< QStringLiteral("media-optical")
|
||||
<< QStringLiteral("device-ipod")
|
||||
<< QStringLiteral("device-ipod-nano")
|
||||
<< QStringLiteral("device-phone");
|
||||
const QStringList icon_names = QStringList() << u"device"_s
|
||||
<< u"device-usb-drive"_s
|
||||
<< u"device-usb-flash"_s
|
||||
<< u"media-optical"_s
|
||||
<< u"device-ipod"_s
|
||||
<< u"device-ipod-nano"_s
|
||||
<< u"device-phone"_s;
|
||||
|
||||
|
||||
for (const QString &icon_name : icon_names) {
|
||||
|
||||
@@ -236,19 +236,19 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
collection_menu_ = new QMenu(this);
|
||||
|
||||
// Device menu
|
||||
eject_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("media-eject")), tr("Safely remove device"), this, &DeviceView::Unmount);
|
||||
forget_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("list-remove")), tr("Forget device"), this, &DeviceView::Forget);
|
||||
eject_action_ = device_menu_->addAction(IconLoader::Load(u"media-eject"_s), tr("Safely remove device"), this, &DeviceView::Unmount);
|
||||
forget_action_ = device_menu_->addAction(IconLoader::Load(u"list-remove"_s), tr("Forget device"), this, &DeviceView::Forget);
|
||||
device_menu_->addSeparator();
|
||||
properties_action_ = device_menu_->addAction(IconLoader::Load(QStringLiteral("configure")), tr("Device properties..."), this, &DeviceView::Properties);
|
||||
properties_action_ = device_menu_->addAction(IconLoader::Load(u"configure"_s), tr("Device properties..."), this, &DeviceView::Properties);
|
||||
|
||||
// Collection menu
|
||||
add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Append to current playlist"), this, &DeviceView::AddToPlaylist);
|
||||
load_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Replace current playlist"), this, &DeviceView::Load);
|
||||
open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("document-new")), tr("Open in new playlist"), this, &DeviceView::OpenInNewPlaylist);
|
||||
add_to_playlist_action_ = collection_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Append to current playlist"), this, &DeviceView::AddToPlaylist);
|
||||
load_action_ = collection_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Replace current playlist"), this, &DeviceView::Load);
|
||||
open_in_new_playlist_ = collection_menu_->addAction(IconLoader::Load(u"document-new"_s), tr("Open in new playlist"), this, &DeviceView::OpenInNewPlaylist);
|
||||
|
||||
collection_menu_->addSeparator();
|
||||
organize_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("edit-copy")), tr("Copy to collection..."), this, &DeviceView::Organize);
|
||||
delete_action_ = collection_menu_->addAction(IconLoader::Load(QStringLiteral("edit-delete")), tr("Delete from device..."), this, &DeviceView::Delete);
|
||||
organize_action_ = collection_menu_->addAction(IconLoader::Load(u"edit-copy"_s), tr("Copy to collection..."), this, &DeviceView::Organize);
|
||||
delete_action_ = collection_menu_->addAction(IconLoader::Load(u"edit-delete"_s), tr("Delete from device..."), this, &DeviceView::Delete);
|
||||
}
|
||||
|
||||
menu_index_ = currentIndex();
|
||||
|
||||
@@ -228,12 +228,12 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
||||
for (QString uri : std::as_const(uris)) {
|
||||
|
||||
// gphoto2 gives invalid hostnames with []:, characters in
|
||||
static const QRegularExpression regex_url_usb(QStringLiteral("//\\[usb:(\\d+),(\\d+)\\]"));
|
||||
uri.replace(regex_url_usb, QStringLiteral("//usb-\\1-\\2"));
|
||||
static const QRegularExpression regex_url_usb(u"//\\[usb:(\\d+),(\\d+)\\]"_s);
|
||||
uri.replace(regex_url_usb, u"//usb-\\1-\\2"_s);
|
||||
|
||||
QUrl url;
|
||||
|
||||
static const QRegularExpression regex_url_schema(QStringLiteral("..+:.*"));
|
||||
static const QRegularExpression regex_url_schema(u"..+:.*"_s);
|
||||
if (uri.contains(regex_url_schema)) {
|
||||
url = QUrl::fromEncoded(uri.toUtf8());
|
||||
}
|
||||
@@ -245,16 +245,16 @@ QList<QUrl> GioLister::MakeDeviceUrls(const QString &id) {
|
||||
|
||||
// Special case for file:// GIO URIs - we have to check whether they point to an ipod.
|
||||
if (url.isLocalFile() && IsIpod(url.path())) {
|
||||
url.setScheme(QStringLiteral("ipod"));
|
||||
url.setScheme(u"ipod"_s);
|
||||
}
|
||||
|
||||
static const QRegularExpression regex_usb_digit(QStringLiteral("usb/(\\d+)/(\\d+)"));
|
||||
static const QRegularExpression regex_usb_digit(u"usb/(\\d+)/(\\d+)"_s);
|
||||
QRegularExpression device_re(regex_usb_digit);
|
||||
QRegularExpressionMatch re_match = device_re.match(unix_device);
|
||||
if (re_match.hasMatch()) {
|
||||
QUrlQuery url_query(url);
|
||||
url_query.addQueryItem(QStringLiteral("busnum"), re_match.captured(1));
|
||||
url_query.addQueryItem(QStringLiteral("devnum"), re_match.captured(2));
|
||||
url_query.addQueryItem(u"busnum"_s, re_match.captured(1));
|
||||
url_query.addQueryItem(u"devnum"_s, re_match.captured(2));
|
||||
url.setQuery(url_query);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
using std::make_shared;
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
@@ -195,12 +196,12 @@ bool GPodDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
bool result = false;
|
||||
if (!job.cover_image_.isNull()) {
|
||||
#ifdef Q_OS_LINUX
|
||||
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/organize");
|
||||
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + u"/organize"_s;
|
||||
#else
|
||||
QString temp_path = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
|
||||
#endif
|
||||
if (!QDir(temp_path).exists()) QDir().mkpath(temp_path);
|
||||
SharedPtr<TemporaryFile> cover_file = make_shared<TemporaryFile>(temp_path + QStringLiteral("/track-albumcover-XXXXXX.jpg"));
|
||||
SharedPtr<TemporaryFile> cover_file = make_shared<TemporaryFile>(temp_path + u"/track-albumcover-XXXXXX.jpg"_s);
|
||||
if (!cover_file->filename().isEmpty()) {
|
||||
const QImage &image = job.cover_image_;
|
||||
if (image.save(cover_file->filename(), "JPG")) {
|
||||
|
||||
@@ -723,18 +723,18 @@ QList<QUrl> MacOsDeviceLister::MakeDeviceUrls(const QString &serial) {
|
||||
const MTPDevice &device = mtp_devices_[serial];
|
||||
QString str = QString::asprintf("gphoto2://usb-%d-%d/", device.bus, device.address);
|
||||
QUrlQuery url_query;
|
||||
url_query.addQueryItem(QStringLiteral("vendor"), device.vendor);
|
||||
url_query.addQueryItem(QStringLiteral("vendor_id"), QString::number(device.vendor_id));
|
||||
url_query.addQueryItem(QStringLiteral("product"), device.product);
|
||||
url_query.addQueryItem(QStringLiteral("product_id"), QString::number(device.product_id));
|
||||
url_query.addQueryItem(QStringLiteral("quirks"), QString::number(device.quirks));
|
||||
url_query.addQueryItem(u"vendor"_s, device.vendor);
|
||||
url_query.addQueryItem(u"vendor_id"_s, QString::number(device.vendor_id));
|
||||
url_query.addQueryItem(u"product"_s, device.product);
|
||||
url_query.addQueryItem(u"product_id"_s, QString::number(device.product_id));
|
||||
url_query.addQueryItem(u"quirks"_s, QString::number(device.quirks));
|
||||
QUrl url(str);
|
||||
url.setQuery(url_query);
|
||||
return QList<QUrl>() << url;
|
||||
}
|
||||
|
||||
if (IsCDDevice(serial)) {
|
||||
return QList<QUrl>() << QUrl(QStringLiteral("cdda:///dev/r") + serial);
|
||||
return QList<QUrl>() << QUrl(u"cdda:///dev/r"_s + serial);
|
||||
}
|
||||
|
||||
QString bsd_name = current_devices_[serial];
|
||||
@@ -762,7 +762,7 @@ QVariantList MacOsDeviceLister::DeviceIcons(const QString &serial) {
|
||||
}
|
||||
|
||||
if (IsCDDevice(serial)) {
|
||||
return QVariantList() << QStringLiteral("media-optical");
|
||||
return QVariantList() << u"media-optical"_s;
|
||||
}
|
||||
|
||||
QString bsd_name = current_devices_[serial];
|
||||
|
||||
@@ -33,11 +33,13 @@
|
||||
#include "core/logging.h"
|
||||
#include "mtpconnection.h"
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent), device_(nullptr) {
|
||||
|
||||
QString hostname = url.host();
|
||||
// Parse the URL
|
||||
static const QRegularExpression host_re(QStringLiteral("^usb-(\\d+)-(\\d+)$"));
|
||||
static const QRegularExpression host_re(u"^usb-(\\d+)-(\\d+)$"_s);
|
||||
|
||||
unsigned int bus_location = 0;
|
||||
unsigned int device_num = 0;
|
||||
@@ -49,9 +51,9 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
||||
bus_location = re_match.captured(1).toUInt();
|
||||
device_num = re_match.captured(2).toUInt();
|
||||
}
|
||||
else if (url_query.hasQueryItem(QStringLiteral("busnum"))) {
|
||||
bus_location = url_query.queryItemValue(QStringLiteral("busnum")).toUInt();
|
||||
device_num = url_query.queryItemValue(QStringLiteral("devnum")).toUInt();
|
||||
else if (url_query.hasQueryItem(u"busnum"_s)) {
|
||||
bus_location = url_query.queryItemValue(u"busnum"_s).toUInt();
|
||||
device_num = url_query.queryItemValue(u"devnum"_s).toUInt();
|
||||
}
|
||||
else {
|
||||
error_text_ = tr("Invalid MTP device: %1").arg(hostname);
|
||||
@@ -59,13 +61,13 @@ MtpConnection::MtpConnection(const QUrl &url, QObject *parent) : QObject(parent)
|
||||
return;
|
||||
}
|
||||
|
||||
if (url_query.hasQueryItem(QStringLiteral("vendor"))) {
|
||||
if (url_query.hasQueryItem(u"vendor"_s)) {
|
||||
LIBMTP_raw_device_t *raw_device = static_cast<LIBMTP_raw_device_t*>(malloc(sizeof(LIBMTP_raw_device_t)));
|
||||
raw_device->device_entry.vendor = url_query.queryItemValue(QStringLiteral("vendor")).toLatin1().data();
|
||||
raw_device->device_entry.product = url_query.queryItemValue(QStringLiteral("product")).toLatin1().data();
|
||||
raw_device->device_entry.vendor_id = url_query.queryItemValue(QStringLiteral("vendor_id")).toUShort();
|
||||
raw_device->device_entry.product_id = url_query.queryItemValue(QStringLiteral("product_id")).toUShort();
|
||||
raw_device->device_entry.device_flags = url_query.queryItemValue(QStringLiteral("quirks")).toUInt();
|
||||
raw_device->device_entry.vendor = url_query.queryItemValue(u"vendor"_s).toLatin1().data();
|
||||
raw_device->device_entry.product = url_query.queryItemValue(u"product"_s).toLatin1().data();
|
||||
raw_device->device_entry.vendor_id = url_query.queryItemValue(u"vendor_id"_s).toUShort();
|
||||
raw_device->device_entry.product_id = url_query.queryItemValue(u"product_id"_s).toUShort();
|
||||
raw_device->device_entry.device_flags = url_query.queryItemValue(u"quirks"_s).toUInt();
|
||||
|
||||
raw_device->bus_location = bus_location;
|
||||
raw_device->devnum = device_num;
|
||||
@@ -122,16 +124,16 @@ QString MtpConnection::ErrorString(const LIBMTP_error_number_t error_number) {
|
||||
|
||||
switch(error_number) {
|
||||
case LIBMTP_ERROR_NO_DEVICE_ATTACHED:
|
||||
return QStringLiteral("No Devices have been found.");
|
||||
return u"No Devices have been found."_s;
|
||||
case LIBMTP_ERROR_CONNECTING:
|
||||
return QStringLiteral("There has been an error connecting.");
|
||||
return u"There has been an error connecting."_s;
|
||||
case LIBMTP_ERROR_MEMORY_ALLOCATION:
|
||||
return QStringLiteral("Memory Allocation Error.");
|
||||
return u"Memory Allocation Error."_s;
|
||||
case LIBMTP_ERROR_GENERAL:
|
||||
default:
|
||||
return QStringLiteral("Unknown error, please report this to the libmtp developers.");
|
||||
return u"Unknown error, please report this to the libmtp developers."_s;
|
||||
case LIBMTP_ERROR_NONE:
|
||||
return QStringLiteral("Successfully connected.");
|
||||
return u"Successfully connected."_s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ MtpDevice::~MtpDevice() {
|
||||
|
||||
bool MtpDevice::Init() {
|
||||
|
||||
InitBackendDirectory(QStringLiteral("/"), first_time_, false);
|
||||
InitBackendDirectory(u"/"_s, first_time_, false);
|
||||
model_->Init();
|
||||
|
||||
loader_ = new MtpLoader(url_, app_->task_manager(), backend_);
|
||||
|
||||
@@ -190,7 +190,7 @@ void Udisks2Lister::UpdateDeviceFreeSpace(const QString &id) {
|
||||
|
||||
bool Udisks2Lister::Init() {
|
||||
|
||||
udisks2_interface_ = make_unique<OrgFreedesktopDBusObjectManagerInterface>(QLatin1String(kUDisks2Service), QStringLiteral("/org/freedesktop/UDisks2"), QDBusConnection::systemBus());
|
||||
udisks2_interface_ = make_unique<OrgFreedesktopDBusObjectManagerInterface>(QLatin1String(kUDisks2Service), u"/org/freedesktop/UDisks2"_s, QDBusConnection::systemBus());
|
||||
|
||||
QDBusPendingReply<ManagedObjectList> reply = udisks2_interface_->GetManagedObjects();
|
||||
reply.waitForFinished();
|
||||
@@ -411,7 +411,7 @@ Udisks2Lister::PartitionData Udisks2Lister::ReadPartitionData(const QDBusObjectP
|
||||
}
|
||||
|
||||
QString Udisks2Lister::PartitionData::unique_id() const {
|
||||
return QStringLiteral("Udisks2/%1/%2/%3/%4/%5")
|
||||
return u"Udisks2/%1/%2/%3/%4/%5"_s
|
||||
.arg(serial, vendor, model)
|
||||
.arg(capacity)
|
||||
.arg(uuid);
|
||||
|
||||
Reference in New Issue
Block a user