mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Add context menu for web seeds: add, remove, copy, edit.
This commit is contained in:
parent
da3406b811
commit
b286bead09
@ -91,6 +91,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, Tra
|
|||||||
connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
|
connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
|
||||||
connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex)));
|
connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex)));
|
||||||
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
|
connect(listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&)));
|
||||||
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
|
connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed()));
|
||||||
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds()));
|
||||||
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle)), this, SLOT(loadTorrentInfos(QTorrentHandle)));
|
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle)), this, SLOT(loadTorrentInfos(QTorrentHandle)));
|
||||||
@ -503,6 +504,34 @@ void PropertiesWidget::displayFilesListMenu(const QPoint&) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::displayWebSeedListMenu(const QPoint&) {
|
||||||
|
QMenu seedMenu;
|
||||||
|
QModelIndexList rows = listWebSeeds->selectionModel()->selectedRows();
|
||||||
|
QAction *actAdd = seedMenu.addAction(IconProvider::instance()->getIcon("list-add"), tr("New Web seed"));
|
||||||
|
QAction *actDel = 0;
|
||||||
|
QAction *actCpy = 0;
|
||||||
|
QAction *actEdit = 0;
|
||||||
|
|
||||||
|
if (rows.size()) {
|
||||||
|
actDel = seedMenu.addAction(IconProvider::instance()->getIcon("list-remove"), tr("Remove Web seed"));
|
||||||
|
seedMenu.addSeparator();
|
||||||
|
actCpy = seedMenu.addAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy Web seed URL"));
|
||||||
|
actEdit = seedMenu.addAction(IconProvider::instance()->getIcon("edit-rename"), tr("Edit Web seed URL"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QAction *act = seedMenu.exec(QCursor::pos());
|
||||||
|
if (act) {
|
||||||
|
if (act == actAdd)
|
||||||
|
askWebSeed();
|
||||||
|
else if (act == actDel)
|
||||||
|
deleteSelectedUrlSeeds();
|
||||||
|
else if (act == actCpy)
|
||||||
|
copySelectedWebSeedsToClipboard();
|
||||||
|
else if (act == actEdit)
|
||||||
|
editWebSeed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PropertiesWidget::renameSelectedFile() {
|
void PropertiesWidget::renameSelectedFile() {
|
||||||
const QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(0);
|
const QModelIndexList selectedIndexes = filesList->selectionModel()->selectedRows(0);
|
||||||
Q_ASSERT(selectedIndexes.size() == 1);
|
Q_ASSERT(selectedIndexes.size() == 1);
|
||||||
@ -633,7 +662,8 @@ void PropertiesWidget::askWebSeed() {
|
|||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
h.add_url_seed(url_seed);
|
if (h.is_valid())
|
||||||
|
h.add_url_seed(url_seed);
|
||||||
// Refresh the seeds list
|
// Refresh the seeds list
|
||||||
loadUrlSeeds();
|
loadUrlSeeds();
|
||||||
}
|
}
|
||||||
@ -643,8 +673,10 @@ void PropertiesWidget::deleteSelectedUrlSeeds() {
|
|||||||
bool change = false;
|
bool change = false;
|
||||||
foreach (const QListWidgetItem *item, selectedItems) {
|
foreach (const QListWidgetItem *item, selectedItems) {
|
||||||
QString url_seed = item->text();
|
QString url_seed = item->text();
|
||||||
h.remove_url_seed(url_seed);
|
try {
|
||||||
change = true;
|
h.remove_url_seed(url_seed);
|
||||||
|
change = true;
|
||||||
|
} catch (invalid_handle&) {}
|
||||||
}
|
}
|
||||||
if (change) {
|
if (change) {
|
||||||
// Refresh list
|
// Refresh list
|
||||||
@ -652,6 +684,46 @@ void PropertiesWidget::deleteSelectedUrlSeeds() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::copySelectedWebSeedsToClipboard() const {
|
||||||
|
const QList<QListWidgetItem *> selected_items = listWebSeeds->selectedItems();
|
||||||
|
if (selected_items.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QStringList urls_to_copy;
|
||||||
|
foreach (QListWidgetItem *item, selected_items)
|
||||||
|
urls_to_copy << item->text();
|
||||||
|
|
||||||
|
QApplication::clipboard()->setText(urls_to_copy.join("\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropertiesWidget::editWebSeed() {
|
||||||
|
const QList<QListWidgetItem *> selected_items = listWebSeeds->selectedItems();
|
||||||
|
if (selected_items.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QListWidgetItem *selected_item = selected_items.last();
|
||||||
|
const QString old_seed = selected_item->text();
|
||||||
|
bool result;
|
||||||
|
const QString new_seed = QInputDialog::getText(this, tr("Web seed editing"),
|
||||||
|
tr("Web seed URL:"), QLineEdit::Normal,
|
||||||
|
old_seed, &result);
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!listWebSeeds->findItems(new_seed, Qt::MatchFixedString).empty()) {
|
||||||
|
QMessageBox::warning(this, tr("qBittorrent"),
|
||||||
|
tr("This url seed is already in the list."),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
h.remove_url_seed(old_seed);
|
||||||
|
h.add_url_seed(new_seed);
|
||||||
|
loadUrlSeeds();
|
||||||
|
} catch (invalid_handle&) {}
|
||||||
|
}
|
||||||
|
|
||||||
bool PropertiesWidget::applyPriorities() {
|
bool PropertiesWidget::applyPriorities() {
|
||||||
qDebug("Saving files priorities");
|
qDebug("Saving files priorities");
|
||||||
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities();
|
const std::vector<int> priorities = PropListModel->model()->getFilesPriorities();
|
||||||
|
@ -78,7 +78,10 @@ protected slots:
|
|||||||
void loadUrlSeeds();
|
void loadUrlSeeds();
|
||||||
void askWebSeed();
|
void askWebSeed();
|
||||||
void deleteSelectedUrlSeeds();
|
void deleteSelectedUrlSeeds();
|
||||||
|
void copySelectedWebSeedsToClipboard() const;
|
||||||
|
void editWebSeed();
|
||||||
void displayFilesListMenu(const QPoint& pos);
|
void displayFilesListMenu(const QPoint& pos);
|
||||||
|
void displayWebSeedListMenu(const QPoint& pos);
|
||||||
void filteredFilesChanged();
|
void filteredFilesChanged();
|
||||||
void showPiecesDownloaded(bool show);
|
void showPiecesDownloaded(bool show);
|
||||||
void showPiecesAvailability(bool show);
|
void showPiecesAvailability(bool show);
|
||||||
|
@ -641,7 +641,14 @@
|
|||||||
<widget class="QWidget" name="page_3">
|
<widget class="QWidget" name="page_3">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="listWebSeeds"/>
|
<widget class="QListWidget" name="listWebSeeds">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="_19">
|
<layout class="QHBoxLayout" name="_19">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user