mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 22:18:05 -06:00
Use QString literals
This patch covers src/gui and some leftovers from previous commit.
This commit is contained in:
@@ -488,7 +488,7 @@ void TransferListWidget::copySelectedMagnetURIs() const
|
||||
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
|
||||
magnetUris << torrent->createMagnetURI();
|
||||
|
||||
qApp->clipboard()->setText(magnetUris.join('\n'));
|
||||
qApp->clipboard()->setText(magnetUris.join(u'\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::copySelectedNames() const
|
||||
@@ -497,7 +497,7 @@ void TransferListWidget::copySelectedNames() const
|
||||
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
|
||||
torrentNames << torrent->name();
|
||||
|
||||
qApp->clipboard()->setText(torrentNames.join('\n'));
|
||||
qApp->clipboard()->setText(torrentNames.join(u'\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::copySelectedInfohashes(const CopyInfohashPolicy policy) const
|
||||
@@ -523,7 +523,7 @@ void TransferListWidget::copySelectedInfohashes(const CopyInfohashPolicy policy)
|
||||
break;
|
||||
}
|
||||
|
||||
qApp->clipboard()->setText(infoHashes.join('\n'));
|
||||
qApp->clipboard()->setText(infoHashes.join(u'\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::copySelectedIDs() const
|
||||
@@ -532,7 +532,7 @@ void TransferListWidget::copySelectedIDs() const
|
||||
for (BitTorrent::Torrent *const torrent : asConst(getSelectedTorrents()))
|
||||
torrentIDs << torrent->id().toString();
|
||||
|
||||
qApp->clipboard()->setText(torrentIDs.join('\n'));
|
||||
qApp->clipboard()->setText(torrentIDs.join(u'\n'));
|
||||
}
|
||||
|
||||
void TransferListWidget::hideQueuePosColumn(bool hide)
|
||||
@@ -776,10 +776,10 @@ QStringList TransferListWidget::askTagsForSelection(const QString &dialogTitle)
|
||||
bool ok = false;
|
||||
invalid = false;
|
||||
const QString tagsInput = AutoExpandableDialog::getText(
|
||||
this, dialogTitle, tr("Comma-separated tags:"), QLineEdit::Normal, "", &ok).trimmed();
|
||||
this, dialogTitle, tr("Comma-separated tags:"), QLineEdit::Normal, {}, &ok).trimmed();
|
||||
if (!ok || tagsInput.isEmpty())
|
||||
return {};
|
||||
tags = tagsInput.split(',', Qt::SkipEmptyParts);
|
||||
tags = tagsInput.split(u',', Qt::SkipEmptyParts);
|
||||
for (QString &tag : tags)
|
||||
{
|
||||
tag = tag.trimmed();
|
||||
@@ -818,7 +818,7 @@ void TransferListWidget::renameSelectedTorrent()
|
||||
QString name = AutoExpandableDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, torrent->name(), &ok);
|
||||
if (ok && !name.isEmpty())
|
||||
{
|
||||
name.replace(QRegularExpression("\r?\n|\r"), " ");
|
||||
name.replace(QRegularExpression(u"\r?\n|\r"_qs), u" "_qs);
|
||||
// Rename the torrent
|
||||
m_listModel->setData(mi, name, Qt::DisplayRole);
|
||||
}
|
||||
@@ -856,47 +856,47 @@ void TransferListWidget::displayListMenu()
|
||||
|
||||
// Create actions
|
||||
|
||||
auto *actionStart = new QAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), listMenu);
|
||||
auto *actionStart = new QAction(UIThemeManager::instance()->getIcon(u"media-playback-start"_qs), tr("Resume", "Resume/start the torrent"), listMenu);
|
||||
connect(actionStart, &QAction::triggered, this, &TransferListWidget::startSelectedTorrents);
|
||||
auto *actionPause = new QAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), listMenu);
|
||||
auto *actionPause = new QAction(UIThemeManager::instance()->getIcon(u"media-playback-pause"_qs), tr("Pause", "Pause the torrent"), listMenu);
|
||||
connect(actionPause, &QAction::triggered, this, &TransferListWidget::pauseSelectedTorrents);
|
||||
auto *actionForceStart = new QAction(UIThemeManager::instance()->getIcon("media-seek-forward"), tr("Force Resume", "Force Resume/start the torrent"), listMenu);
|
||||
auto *actionForceStart = new QAction(UIThemeManager::instance()->getIcon(u"media-seek-forward"_qs), tr("Force Resume", "Force Resume/start the torrent"), listMenu);
|
||||
connect(actionForceStart, &QAction::triggered, this, &TransferListWidget::forceStartSelectedTorrents);
|
||||
auto *actionDelete = new QAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete", "Delete the torrent"), listMenu);
|
||||
auto *actionDelete = new QAction(UIThemeManager::instance()->getIcon(u"list-remove"_qs), tr("Delete", "Delete the torrent"), listMenu);
|
||||
connect(actionDelete, &QAction::triggered, this, &TransferListWidget::softDeleteSelectedTorrents);
|
||||
auto *actionPreviewFile = new QAction(UIThemeManager::instance()->getIcon("view-preview"), tr("Preview file..."), listMenu);
|
||||
auto *actionPreviewFile = new QAction(UIThemeManager::instance()->getIcon(u"view-preview"_qs), tr("Preview file..."), listMenu);
|
||||
connect(actionPreviewFile, &QAction::triggered, this, &TransferListWidget::previewSelectedTorrents);
|
||||
auto *actionTorrentOptions = new QAction(UIThemeManager::instance()->getIcon("configure"), tr("Torrent options..."), listMenu);
|
||||
auto *actionTorrentOptions = new QAction(UIThemeManager::instance()->getIcon(u"configure"_qs), tr("Torrent options..."), listMenu);
|
||||
connect(actionTorrentOptions, &QAction::triggered, this, &TransferListWidget::setTorrentOptions);
|
||||
auto *actionOpenDestinationFolder = new QAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open destination folder"), listMenu);
|
||||
auto *actionOpenDestinationFolder = new QAction(UIThemeManager::instance()->getIcon(u"inode-directory"_qs), tr("Open destination folder"), listMenu);
|
||||
connect(actionOpenDestinationFolder, &QAction::triggered, this, &TransferListWidget::openSelectedTorrentsFolder);
|
||||
auto *actionIncreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-up"), tr("Move up", "i.e. move up in the queue"), listMenu);
|
||||
auto *actionIncreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon(u"go-up"_qs), tr("Move up", "i.e. move up in the queue"), listMenu);
|
||||
connect(actionIncreaseQueuePos, &QAction::triggered, this, &TransferListWidget::increaseQueuePosSelectedTorrents);
|
||||
auto *actionDecreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-down"), tr("Move down", "i.e. Move down in the queue"), listMenu);
|
||||
auto *actionDecreaseQueuePos = new QAction(UIThemeManager::instance()->getIcon(u"go-down"_qs), tr("Move down", "i.e. Move down in the queue"), listMenu);
|
||||
connect(actionDecreaseQueuePos, &QAction::triggered, this, &TransferListWidget::decreaseQueuePosSelectedTorrents);
|
||||
auto *actionTopQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-top"), tr("Move to top", "i.e. Move to top of the queue"), listMenu);
|
||||
auto *actionTopQueuePos = new QAction(UIThemeManager::instance()->getIcon(u"go-top"_qs), tr("Move to top", "i.e. Move to top of the queue"), listMenu);
|
||||
connect(actionTopQueuePos, &QAction::triggered, this, &TransferListWidget::topQueuePosSelectedTorrents);
|
||||
auto *actionBottomQueuePos = new QAction(UIThemeManager::instance()->getIcon("go-bottom"), tr("Move to bottom", "i.e. Move to bottom of the queue"), listMenu);
|
||||
auto *actionBottomQueuePos = new QAction(UIThemeManager::instance()->getIcon(u"go-bottom"_qs), tr("Move to bottom", "i.e. Move to bottom of the queue"), listMenu);
|
||||
connect(actionBottomQueuePos, &QAction::triggered, this, &TransferListWidget::bottomQueuePosSelectedTorrents);
|
||||
auto *actionSetTorrentPath = new QAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Set location..."), listMenu);
|
||||
auto *actionSetTorrentPath = new QAction(UIThemeManager::instance()->getIcon(u"inode-directory"_qs), tr("Set location..."), listMenu);
|
||||
connect(actionSetTorrentPath, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsLocation);
|
||||
auto *actionForceRecheck = new QAction(UIThemeManager::instance()->getIcon("document-edit-verify"), tr("Force recheck"), listMenu);
|
||||
auto *actionForceRecheck = new QAction(UIThemeManager::instance()->getIcon(u"document-edit-verify"_qs), tr("Force recheck"), listMenu);
|
||||
connect(actionForceRecheck, &QAction::triggered, this, &TransferListWidget::recheckSelectedTorrents);
|
||||
auto *actionForceReannounce = new QAction(UIThemeManager::instance()->getIcon("document-edit-verify"), tr("Force reannounce"), listMenu);
|
||||
auto *actionForceReannounce = new QAction(UIThemeManager::instance()->getIcon(u"document-edit-verify"_qs), tr("Force reannounce"), listMenu);
|
||||
connect(actionForceReannounce, &QAction::triggered, this, &TransferListWidget::reannounceSelectedTorrents);
|
||||
auto *actionCopyMagnetLink = new QAction(UIThemeManager::instance()->getIcon("kt-magnet"), tr("Magnet link"), listMenu);
|
||||
auto *actionCopyMagnetLink = new QAction(UIThemeManager::instance()->getIcon(u"kt-magnet"_qs), tr("Magnet link"), listMenu);
|
||||
connect(actionCopyMagnetLink, &QAction::triggered, this, &TransferListWidget::copySelectedMagnetURIs);
|
||||
auto *actionCopyID = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Torrent ID"), listMenu);
|
||||
auto *actionCopyID = new QAction(UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Torrent ID"), listMenu);
|
||||
connect(actionCopyID, &QAction::triggered, this, &TransferListWidget::copySelectedIDs);
|
||||
auto *actionCopyName = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Name"), listMenu);
|
||||
auto *actionCopyName = new QAction(UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Name"), listMenu);
|
||||
connect(actionCopyName, &QAction::triggered, this, &TransferListWidget::copySelectedNames);
|
||||
auto *actionCopyHash1 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v1"), listMenu);
|
||||
auto *actionCopyHash1 = new QAction(UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Info hash v1"), listMenu);
|
||||
connect(actionCopyHash1, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version1); });
|
||||
auto *actionCopyHash2 = new QAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Info hash v2"), listMenu);
|
||||
auto *actionCopyHash2 = new QAction(UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Info hash v2"), listMenu);
|
||||
connect(actionCopyHash2, &QAction::triggered, this, [this]() { copySelectedInfohashes(CopyInfohashPolicy::Version2); });
|
||||
auto *actionSuperSeedingMode = new TriStateAction(tr("Super seeding mode"), listMenu);
|
||||
connect(actionSuperSeedingMode, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSuperSeeding);
|
||||
auto *actionRename = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."), listMenu);
|
||||
auto *actionRename = new QAction(UIThemeManager::instance()->getIcon(u"edit-rename"_qs), tr("Rename..."), listMenu);
|
||||
connect(actionRename, &QAction::triggered, this, &TransferListWidget::renameSelectedTorrent);
|
||||
auto *actionSequentialDownload = new TriStateAction(tr("Download in sequential order"), listMenu);
|
||||
connect(actionSequentialDownload, &QAction::triggered, this, &TransferListWidget::setSelectedTorrentsSequentialDownload);
|
||||
@@ -905,7 +905,7 @@ void TransferListWidget::displayListMenu()
|
||||
auto *actionAutoTMM = new TriStateAction(tr("Automatic Torrent Management"), listMenu);
|
||||
actionAutoTMM->setToolTip(tr("Automatic mode means that various torrent properties (e.g. save path) will be decided by the associated category"));
|
||||
connect(actionAutoTMM, &QAction::triggered, this, &TransferListWidget::setSelectedAutoTMMEnabled);
|
||||
auto *actionEditTracker = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit trackers..."), listMenu);
|
||||
auto *actionEditTracker = new QAction(UIThemeManager::instance()->getIcon(u"edit-rename"_qs), tr("Edit trackers..."), listMenu);
|
||||
connect(actionEditTracker, &QAction::triggered, this, &TransferListWidget::editTorrentTrackers);
|
||||
// End of actions
|
||||
|
||||
@@ -1045,18 +1045,18 @@ void TransferListWidget::displayListMenu()
|
||||
QStringList categories = BitTorrent::Session::instance()->categories();
|
||||
std::sort(categories.begin(), categories.end(), Utils::Compare::NaturalLessThan<Qt::CaseInsensitive>());
|
||||
|
||||
QMenu *categoryMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Category"));
|
||||
QMenu *categoryMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon(u"view-categories"_qs), tr("Category"));
|
||||
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New...", "New category...")
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon(u"list-add"_qs), tr("New...", "New category...")
|
||||
, this, &TransferListWidget::askNewCategoryForSelection);
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Reset", "Reset category")
|
||||
, this, [this]() { setSelectionCategory(""); });
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon(u"edit-clear"_qs), tr("Reset", "Reset category")
|
||||
, this, [this]() { setSelectionCategory(u""_qs); });
|
||||
categoryMenu->addSeparator();
|
||||
|
||||
for (const QString &category : asConst(categories))
|
||||
{
|
||||
const QString escapedCategory = QString(category).replace('&', "&&"); // avoid '&' becomes accelerator key
|
||||
QAction *categoryAction = categoryMenu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), escapedCategory
|
||||
const QString escapedCategory = QString(category).replace(u'&', u"&&"_qs); // avoid '&' becomes accelerator key
|
||||
QAction *categoryAction = categoryMenu->addAction(UIThemeManager::instance()->getIcon(u"inode-directory"_qs), escapedCategory
|
||||
, this, [this, category]() { setSelectionCategory(category); });
|
||||
|
||||
if (allSameCategory && (category == firstCategory))
|
||||
@@ -1070,11 +1070,11 @@ void TransferListWidget::displayListMenu()
|
||||
QStringList tags(BitTorrent::Session::instance()->tags().values());
|
||||
std::sort(tags.begin(), tags.end(), Utils::Compare::NaturalLessThan<Qt::CaseInsensitive>());
|
||||
|
||||
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags"));
|
||||
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon(u"view-categories"_qs), tr("Tags"));
|
||||
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags...")
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon(u"list-add"_qs), tr("Add...", "Add / assign multiple tags...")
|
||||
, this, &TransferListWidget::askAddTagsForSelection);
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags")
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon(u"edit-clear"_qs), tr("Remove All", "Remove all tags")
|
||||
, this, [this]()
|
||||
{
|
||||
if (Preferences::instance()->confirmRemoveAllTags())
|
||||
@@ -1163,7 +1163,7 @@ void TransferListWidget::displayListMenu()
|
||||
}
|
||||
|
||||
QMenu *copySubMenu = listMenu->addMenu(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
|
||||
UIThemeManager::instance()->getIcon(u"edit-copy"_qs), tr("Copy"));
|
||||
copySubMenu->addAction(actionCopyName);
|
||||
copySubMenu->addAction(actionCopyHash1);
|
||||
actionCopyHash1->setEnabled(hasInfohashV1);
|
||||
|
||||
Reference in New Issue
Block a user