From 623933e2aa41d3548815d100a0d3c347c98f25ed Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 18 Nov 2009 12:11:15 +0000 Subject: [PATCH] - COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions) - Delete useless properties button in top tool bar - Set Alt+P keyboard shortcut to toggle torrent properties visibility --- Changelog | 1 + src/GUI.cpp | 5 -- src/Icons/oxygen/dialog-warning.png | Bin 0 -> 3422 bytes src/MainWindow.ui | 17 +--- src/TransferListWidget.cpp | 55 +++---------- src/TransferListWidget.h | 1 - src/bittorrent.cpp | 10 +-- src/bittorrent.h | 2 +- src/confirmdeletiondlg.ui | 123 ++++++++++++++++++++++++++++ src/deletionconfirmationdlg.h | 60 ++++++++++++++ src/icons.qrc | 1 + src/propertieswidget.cpp | 1 + src/src.pro | 9 +- 13 files changed, 212 insertions(+), 73 deletions(-) create mode 100644 src/Icons/oxygen/dialog-warning.png create mode 100644 src/confirmdeletiondlg.ui create mode 100644 src/deletionconfirmationdlg.h diff --git a/Changelog b/Changelog index 0c1f9f612..a2a9cda6b 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ - COSMETIC: Made program preferences scrollable for usability on small screens (e.g. netbooks) - COSMETIC: Added a "torrent status" column to transfer list - COSMETIC: Display Seeds and Peers in two separate columns + - COSMETIC: New deletion confirmation dialog (Merged delete/delete permanently actions) * Thu Sep 3 2009 - Christophe Dumez - v1.5.0 - FEATURE: Added Magnet URI support diff --git a/src/GUI.cpp b/src/GUI.cpp index 9abce1c44..f890ca8f9 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -121,8 +121,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis prioSeparator2 = menu_Edit->insertSeparator(actionDecreasePriority); prioSeparator->setVisible(false); prioSeparator2->setVisible(false); - actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png"))); - actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png"))); actionCreate_torrent->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/new.png"))); // Fix Tool bar layout toolBar->layout()->setSpacing(7); @@ -158,7 +156,6 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis connect(actionPause, SIGNAL(triggered()), transferList, SLOT(pauseSelectedTorrents())); connect(actionPause_All, SIGNAL(triggered()), transferList, SLOT(pauseAllTorrents())); connect(actionDelete, SIGNAL(triggered()), transferList, SLOT(deleteSelectedTorrents())); - connect(actionDelete_Permanently, SIGNAL(triggered()), transferList, SLOT(deletePermSelectedTorrents())); connect(actionIncreasePriority, SIGNAL(triggered()), transferList, SLOT(increasePrioSelectedTorrents())); connect(actionDecreasePriority, SIGNAL(triggered()), transferList, SLOT(decreasePrioSelectedTorrents())); @@ -397,10 +394,8 @@ void GUI::createKeyboardShortcuts() { connect(switchSearchShortcut2, SIGNAL(activated()), this, SLOT(displaySearchTab())); switchRSSShortcut = new QShortcut(QKeySequence(tr("Alt+4", "shortcut to switch to fourth tab")), this); connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab())); - actionTorrent_Properties->setShortcut(QKeySequence(QString::fromUtf8("Alt+P"))); actionOptions->setShortcut(QKeySequence(QString::fromUtf8("Alt+O"))); actionDelete->setShortcut(QKeySequence(QString::fromUtf8("Del"))); - actionDelete_Permanently->setShortcut(QKeySequence(QString::fromUtf8("Shift+Del"))); actionStart->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+S"))); actionStart_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+S"))); actionPause->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+P"))); diff --git a/src/Icons/oxygen/dialog-warning.png b/src/Icons/oxygen/dialog-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..0666a3903269582bcd257ebb61b14fd346ea4d1f GIT binary patch literal 3422 zcmV-k4WaUhP)G5|Sr!Q-Kma@M0sI^U3SW|cAWwNo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g#Sh3=m}>3`Yi3Ux;xo!4!dFhI;W+{Q<@G^Kn2Uz09M5ur*Q zwcC>O%-Ep`%A1xE6ZHhxi$Q_+@pBZPFPDe{(tMuA0|zjrD#%Rp43?Zb3 z)%D4et5^1a1vm5x_{(_VDeT~)y>_tL2CLAGCb*5G_@%Ip&TYW>Du{sUrT2gmN`jWA z*Tu#zm8EnOM6UyYUS{CZC+Hsk(;`BEI>D%-L!}spCxt-@P>$0C|4uL(&53z^L)too z8~ZlsB8URgFStH+gGlIC*Pp0fE2xVCI$o)7 zU-|pyTj6)2mwz0zT0{6&o#_3L=#6t+&BYGaaFaura)@nsjI~jH+sbJyui{x5d<;HM zn`69YjQpUsIdLmz(ud=Pa4eY%gXH{zl7w8%C7oSHTT8gfO6)4>`PxkTN5=T?<9MBa zBI3xPe~c8r1;&WD31@Etokpmm#$YIl&#j>JD+a~0R_X2UFVUZmIj#cu6k!=JZzJhz zB>aYR%;moU1`<%b3=LDkGDMj=LV!VlqO2u`0OfZn(PclQ=;u+Cn1~h19sDC9PpiMo z{|t!$!fAwSsl0^pGz$F#{PNG!@a11;ztH9X0hvkd*MPx#07*qoM6N<$f`G?Y A>;M1& literal 0 HcmV?d00001 diff --git a/src/MainWindow.ui b/src/MainWindow.ui index e3fe70399..f1c467d2e 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -25,7 +25,7 @@ 0 0 914 - 23 + 27 @@ -38,10 +38,8 @@ - - @@ -107,9 +105,6 @@ - - - @@ -174,16 +169,6 @@ Visit website - - - Delete Permanently - - - - - Torrent Properties - - Download from URL diff --git a/src/TransferListWidget.cpp b/src/TransferListWidget.cpp index cbd5c5e8d..72aab6e97 100644 --- a/src/TransferListWidget.cpp +++ b/src/TransferListWidget.cpp @@ -35,6 +35,7 @@ #include "previewSelect.h" #include "speedlimitdlg.h" #include "options_imp.h" +#include "deletionconfirmationdlg.h" #include #include #include @@ -477,46 +478,19 @@ void TransferListWidget::pauseAllTorrents() { void TransferListWidget::deleteSelectedTorrents() { QModelIndexList selectedIndexes = selectionModel()->selectedRows(); if(!selectedIndexes.empty()) { - int ret = QMessageBox::question( - this, - tr("Deletion confirmation"), - tr("Are you sure you want to delete the selected torrents from transfer list?"), - tr("&Yes"), tr("&No"), - QString(), 0, 1); - if(ret) return; - QStringList hashes; - foreach(const QModelIndex &index, selectedIndexes) { - // Get the file hash - hashes << getHashFromRow(proxyModel->mapToSource(index).row()); + bool delete_local_files = false; + if(DeletionConfirmationDlg::askForDeletionConfirmation(&delete_local_files)) { + QStringList hashes; + foreach(const QModelIndex &index, selectedIndexes) { + // Get the file hash + hashes << getHashFromRow(proxyModel->mapToSource(index).row()); + } + foreach(const QString &hash, hashes) { + deleteTorrent(getRowFromHash(hash), false); + BTSession->deleteTorrent(hash, delete_local_files); + } + refreshList(); } - foreach(const QString &hash, hashes) { - deleteTorrent(getRowFromHash(hash), false); - BTSession->deleteTorrent(hash, false); - } - refreshList(); - } -} - -void TransferListWidget::deletePermSelectedTorrents() { - QModelIndexList selectedIndexes = selectionModel()->selectedRows(); - if(!selectedIndexes.empty()) { - int ret = QMessageBox::question( - this, - tr("Deletion confirmation"), - tr("Are you sure you want to delete the selected torrents from transfe list and hard disk?"), - tr("&Yes"), tr("&No"), - QString(), 0, 1); - if(ret) return; - QStringList hashes; - foreach(const QModelIndex &index, selectedIndexes) { - // Get the file hash - hashes << getHashFromRow(proxyModel->mapToSource(index).row()); - } - foreach(const QString &hash, hashes) { - deleteTorrent(getRowFromHash(hash), false); - BTSession->deleteTorrent(hash, true); - } - refreshList(); } } @@ -765,8 +739,6 @@ void TransferListWidget::displayListMenu(const QPoint&) { connect(&actionSet_upload_limit, SIGNAL(triggered()), this, SLOT(setUpLimitSelectedTorrents())); QAction actionSet_download_limit(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")), tr("Limit download rate"), 0); connect(&actionSet_download_limit, SIGNAL(triggered()), this, SLOT(setDlLimitSelectedTorrents())); - QAction actionDelete_Permanently(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png")), tr("Delete Permanently"), 0); - connect(&actionDelete_Permanently, SIGNAL(triggered()), this, SLOT(deletePermSelectedTorrents())); QAction actionOpen_destination_folder(QIcon(QString::fromUtf8(":/Icons/oxygen/folder.png")), tr("Open destination folder"), 0); connect(&actionOpen_destination_folder, SIGNAL(triggered()), this, SLOT(openSelectedTorrentsFolder())); QAction actionBuy_it(QIcon(QString::fromUtf8(":/Icons/oxygen/wallet.png")), tr("Buy it"), 0); @@ -833,7 +805,6 @@ void TransferListWidget::displayListMenu(const QPoint&) { } listMenu.addSeparator(); listMenu.addAction(&actionDelete); - listMenu.addAction(&actionDelete_Permanently); listMenu.addSeparator(); if(one_not_seed) listMenu.addAction(&actionSet_download_limit); diff --git a/src/TransferListWidget.h b/src/TransferListWidget.h index adae1aa66..3516b7174 100644 --- a/src/TransferListWidget.h +++ b/src/TransferListWidget.h @@ -92,7 +92,6 @@ public slots: void pauseSelectedTorrents(); void pauseAllTorrents(); void deleteSelectedTorrents(); - void deletePermSelectedTorrents(); void increasePrioSelectedTorrents(); void decreasePrioSelectedTorrents(); void buySelectedTorrents() const; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index e1bc8ea4b..29cd36f10 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -526,7 +526,7 @@ void bittorrent::banIP(QString ip) { // Delete a torrent from the session, given its hash // permanent = true means that the torrent will be removed from the hard-drive too -void bittorrent::deleteTorrent(QString hash, bool permanent) { +void bittorrent::deleteTorrent(QString hash, bool delete_local_files) { qDebug("Deleting torrent with hash: %s", hash.toLocal8Bit().data()); QTorrentHandle h = getTorrentHandle(hash); if(!h.is_valid()) { @@ -536,7 +536,7 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { QString savePath = h.save_path(); QString fileName = h.name(); // Remove it from session - if(permanent) + if(delete_local_files) s->remove_torrent(h.get_torrent_handle(), session::delete_files); else s->remove_torrent(h.get_torrent_handle()); @@ -551,10 +551,10 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { TorrentPersistentData::deletePersistentData(hash); // Remove tracker errors trackersErrors.remove(hash); - if(permanent) - addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName)); + if(delete_local_files) + addConsoleMessage(tr("'%1' was removed from transfer list and hard disk.", "'xxx.avi' was removed...").arg(fileName)); else - addConsoleMessage(tr("'%1' was removed.", "'xxx.avi' was removed.").arg(fileName)); + addConsoleMessage(tr("'%1' was removed from transfer list.", "'xxx.avi' was removed...").arg(fileName)); emit deletedTorrent(hash); } diff --git a/src/bittorrent.h b/src/bittorrent.h index cf0a6cb4c..84a710621 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -119,7 +119,7 @@ class bittorrent : public QObject { void loadSessionState(); void saveSessionState(); void downloadFromUrl(QString url); - void deleteTorrent(QString hash, bool permanent = false); + void deleteTorrent(QString hash, bool delete_local_files = false); void startUpTorrents(); /* Needed by Web UI */ void pauseAllTorrents(); diff --git a/src/confirmdeletiondlg.ui b/src/confirmdeletiondlg.ui new file mode 100644 index 000000000..4ea212e69 --- /dev/null +++ b/src/confirmdeletiondlg.ui @@ -0,0 +1,123 @@ + + + confirmDeletionDlg + + + + 0 + 0 + 377 + 138 + + + + Deletion confirmation - qBittorrent + + + + + 30 + 100 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + 90 + 0 + 281 + 61 + + + + Are you sure you want to delete the selected torrents from the transfer list? + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + 20 + 70 + 351 + 23 + + + + + true + + + + Delete the files on the hard disk as well + + + + + + 10 + 0 + 61 + 61 + + + + + + + :/Icons/oxygen/dialog-warning.png + + + + + + + + + buttonBox + accepted() + confirmDeletionDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + confirmDeletionDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/deletionconfirmationdlg.h b/src/deletionconfirmationdlg.h new file mode 100644 index 000000000..845cc1d19 --- /dev/null +++ b/src/deletionconfirmationdlg.h @@ -0,0 +1,60 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2006 Christophe Dumez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#ifndef DELETIONCONFIRMATIONDLG_H +#define DELETIONCONFIRMATIONDLG_H + +#include +#include "ui_confirmdeletiondlg.h" + +class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { + Q_OBJECT + + public: + DeletionConfirmationDlg(QWidget *parent=0): QDialog(parent) { + setupUi(this); + } + + bool shouldDeleteLocalFiles() const { + return checkPermDelete->isChecked(); + } + + static bool askForDeletionConfirmation(bool *delete_local_files) { + DeletionConfirmationDlg dlg; + if(dlg.exec() == QDialog::Accepted) { + *delete_local_files = dlg.shouldDeleteLocalFiles(); + return true; + } + return false; + } + +}; + +#endif // DELETIONCONFIRMATIONDLG_H diff --git a/src/icons.qrc b/src/icons.qrc index 239136387..d554cb511 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -120,6 +120,7 @@ Icons/oxygen/gear.png Icons/oxygen/draw-triangle2.png Icons/oxygen/remove.png + Icons/oxygen/dialog-warning.png Icons/oxygen/peer.png Icons/oxygen/browse.png Icons/oxygen/unsubscribe16.png diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index ff1413f7b..5d721b2a7 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -67,6 +67,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer url_seeds_button->setStyleSheet(DEFAULT_BUTTON_CSS); files_button->setStyleSheet(DEFAULT_BUTTON_CSS); main_infos_button->setStyleSheet(DEFAULT_BUTTON_CSS); + main_infos_button->setShortcut(QKeySequence(QString::fromUtf8("Alt+P"))); // Set Properties list model PropListModel = new TorrentFilesModel(); diff --git a/src/src.pro b/src/src.pro index 62eaeb9c2..f184a39f8 100644 --- a/src/src.pro +++ b/src/src.pro @@ -18,7 +18,8 @@ DEFINES += VERSION=\\\"v2.0.0beta2\\\" DEFINES += VERSION_MAJOR=2 DEFINES += VERSION_MINOR=0 DEFINES += VERSION_BUGFIX=0 -#!mac:QMAKE_LFLAGS += -Wl,--as-needed + +# !mac:QMAKE_LFLAGS += -Wl,--as-needed contains(DEBUG_MODE, 1) { CONFIG += debug CONFIG -= release @@ -192,7 +193,8 @@ HEADERS += GUI.h \ reverseresolution.h \ preferences.h \ geoip.h \ - peeraddition.h + peeraddition.h \ + deletionconfirmationdlg.h FORMS += MainWindow.ui \ options.ui \ about.ui \ @@ -210,7 +212,8 @@ FORMS += MainWindow.ui \ console.ui \ FeedDownloader.ui \ propertiesWidget.ui \ - peer.ui + peer.ui \ + confirmdeletiondlg.ui SOURCES += GUI.cpp \ main.cpp \ options_imp.cpp \