2006-09-30 20:02:39 +04:00
/*
* Bittorrent Client using Qt4 and libtorrent .
2007-07-14 18:31:59 +04:00
* Copyright ( C ) 2006 Christophe Dumez
2006-09-30 20:02:39 +04:00
*
2007-07-14 18:31:59 +04:00
* 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 .
2006-09-30 20:02:39 +04:00
*
* 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
2007-07-14 18:31:59 +04:00
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
* Contact : chris @ qbittorrent . org
2006-09-30 20:02:39 +04:00
*/
# include <QFileDialog>
# include <QTime>
# include <QMessageBox>
# include <QDesktopWidget>
# include <QTimer>
2006-12-27 06:19:38 +03:00
# include <QDesktopServices>
2007-03-27 22:49:29 +04:00
# include <QTcpServer>
# include <QTcpSocket>
# include <QCloseEvent>
2007-07-19 16:58:45 +04:00
# include <QShortcut>
2007-07-23 16:46:36 +04:00
# include <QStandardItemModel>
2007-07-25 13:03:22 +04:00
# include <QMutexLocker>
2006-12-28 02:56:30 +03:00
2006-09-30 20:02:39 +04:00
# include "GUI.h"
# include "misc.h"
# include "createtorrent_imp.h"
# include "properties_imp.h"
# include "DLListDelegate.h"
# include "downloadThread.h"
# include "downloadFromURLImp.h"
2006-10-24 01:42:37 +04:00
# include "torrentAddition.h"
2007-03-27 22:49:29 +04:00
# include "searchEngine.h"
2007-03-29 19:43:08 +04:00
# include "rss_imp.h"
2007-04-04 05:36:55 +04:00
# include "FinishedTorrents.h"
2007-04-10 13:07:33 +04:00
# include "allocationDlg.h"
2007-07-23 16:12:55 +04:00
# include "bittorrent.h"
2007-07-23 16:46:36 +04:00
# include "about_imp.h"
# include "trackerLogin.h"
# include "previewSelect.h"
# include "options_imp.h"
2007-03-04 20:13:29 +03:00
2006-09-30 20:02:39 +04:00
/*****************************************************
* *
* GUI *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Constructor
GUI : : GUI ( QWidget * parent , QStringList torrentCmdLine ) : QMainWindow ( parent ) {
setupUi ( this ) ;
2007-03-09 01:51:52 +03:00
setWindowTitle ( tr ( " qBittorrent %1 " , " e.g: qBittorrent v0.x " ) . arg ( VERSION ) ) ;
2007-04-10 13:31:25 +04:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
systrayIntegration = settings . value ( " Options/Misc/Behaviour/SystrayIntegration " , true ) . toBool ( ) ;
2007-04-10 13:35:34 +04:00
// Create tray icon
if ( QSystemTrayIcon : : isSystemTrayAvailable ( ) ) {
if ( systrayIntegration ) {
createTrayIcon ( ) ;
}
} else {
systrayIntegration = false ;
qDebug ( " Info: System tray unavailable \n " ) ;
}
2007-06-29 02:13:01 +04:00
delayedSorting = false ;
2007-07-14 16:35:04 +04:00
BTSession = new bittorrent ( ) ;
2007-04-04 16:01:32 +04:00
// Finished torrents tab
2007-07-14 16:35:04 +04:00
finishedTorrentTab = new FinishedTorrents ( this , BTSession ) ;
2007-04-04 16:01:32 +04:00
tabs - > addTab ( finishedTorrentTab , tr ( " Finished " ) ) ;
tabs - > setTabIcon ( 1 , QIcon ( QString : : fromUtf8 ( " :/Icons/skin/seeding.png " ) ) ) ;
2007-04-15 22:15:22 +04:00
connect ( finishedTorrentTab , SIGNAL ( torrentMovedFromFinishedList ( torrent_handle ) ) , this , SLOT ( restoreInDownloadList ( torrent_handle ) ) ) ;
2007-04-05 23:42:39 +04:00
// Tabs text
nbTorrents = 0 ;
tabs - > setTabText ( 0 , tr ( " Downloads " ) + " (0) " ) ;
tabs - > setTabText ( 1 , tr ( " Finished " ) + " (0) " ) ;
2006-09-30 20:02:39 +04:00
// Setting icons
this - > setWindowIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/qbittorrent32.png " ) ) ) ;
actionOpen - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/open.png " ) ) ) ;
actionExit - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/exit.png " ) ) ) ;
actionDownload_from_URL - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/url.png " ) ) ) ;
actionOptions - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/settings.png " ) ) ) ;
actionAbout - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/info.png " ) ) ) ;
2006-12-27 06:19:38 +03:00
actionWebsite - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/qbittorrent32.png " ) ) ) ;
actionBugReport - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/newmsg.png " ) ) ) ;
2006-09-30 20:02:39 +04:00
actionStart - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/play.png " ) ) ) ;
actionPause - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/pause.png " ) ) ) ;
actionDelete - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/delete.png " ) ) ) ;
actionPause_All - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/pause_all.png " ) ) ) ;
actionStart_All - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/play_all.png " ) ) ) ;
actionClearLog - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/delete.png " ) ) ) ;
actionPreview_file - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/preview.png " ) ) ) ;
2007-04-10 14:50:34 +04:00
actionSet_upload_limit - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/seeding.png " ) ) ) ;
actionSet_download_limit - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/downloading.png " ) ) ) ;
2007-07-14 14:50:38 +04:00
actionSet_global_upload_limit - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/seeding.png " ) ) ) ;
actionSet_global_download_limit - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/downloading.png " ) ) ) ;
2007-06-19 19:11:02 +04:00
actionDocumentation - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/qb_question.png " ) ) ) ;
2006-10-23 00:13:35 +04:00
connecStatusLblIcon = new QLabel ( ) ;
connecStatusLblIcon - > setFrameShape ( QFrame : : NoFrame ) ;
connecStatusLblIcon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/skin/disconnected.png " ) ) ) ;
2007-03-09 01:51:52 +03:00
connecStatusLblIcon - > setToolTip ( " <b> " + tr ( " Connection status: " ) + " </b><br> " + tr ( " Offline " ) + " <br><i> " + tr ( " No peers found... " ) + " </i> " ) ;
2006-10-23 00:13:35 +04:00
toolBar - > addWidget ( connecStatusLblIcon ) ;
2006-10-29 13:17:53 +03:00
actionDelete_Permanently - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/delete_perm.png " ) ) ) ;
2006-09-30 20:02:39 +04:00
actionTorrent_Properties - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/properties.png " ) ) ) ;
actionCreate_torrent - > setIcon ( QIcon ( QString : : fromUtf8 ( " :/Icons/skin/new.png " ) ) ) ;
2007-07-04 10:42:36 +04:00
// tabBottom->setTabIcon(0, QIcon(QString::fromUtf8(":/Icons/log.png")));
// tabBottom->setTabIcon(1, QIcon(QString::fromUtf8(":/Icons/filter.png")));
2007-04-04 05:36:55 +04:00
tabs - > setTabIcon ( 0 , QIcon ( QString : : fromUtf8 ( " :/Icons/skin/downloading.png " ) ) ) ;
2006-09-30 20:02:39 +04:00
// Set default ratio
lbl_ratio_icon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/stare.png " ) ) ) ;
// Fix Tool bar layout
toolBar - > layout ( ) - > setSpacing ( 7 ) ;
// Set Download list model
2007-02-24 01:52:24 +03:00
DLListModel = new QStandardItemModel ( 0 , 9 ) ;
2007-03-09 01:51:52 +03:00
DLListModel - > setHeaderData ( NAME , Qt : : Horizontal , tr ( " Name " , " i.e: file name " ) ) ;
DLListModel - > setHeaderData ( SIZE , Qt : : Horizontal , tr ( " Size " , " i.e: file size " ) ) ;
DLListModel - > setHeaderData ( PROGRESS , Qt : : Horizontal , tr ( " Progress " , " i.e: % downloaded " ) ) ;
DLListModel - > setHeaderData ( DLSPEED , Qt : : Horizontal , tr ( " DL Speed " , " i.e: Download speed " ) ) ;
DLListModel - > setHeaderData ( UPSPEED , Qt : : Horizontal , tr ( " UP Speed " , " i.e: Upload speed " ) ) ;
DLListModel - > setHeaderData ( SEEDSLEECH , Qt : : Horizontal , tr ( " Seeds/Leechs " , " i.e: full/partial sources " ) ) ;
2007-07-18 11:44:52 +04:00
DLListModel - > setHeaderData ( RATIO , Qt : : Horizontal , tr ( " Ratio " ) ) ;
2007-03-09 01:51:52 +03:00
DLListModel - > setHeaderData ( ETA , Qt : : Horizontal , tr ( " ETA " , " i.e: Estimated Time of Arrival / Time left " ) ) ;
2006-09-30 20:02:39 +04:00
downloadList - > setModel ( DLListModel ) ;
2007-04-11 22:31:21 +04:00
DLDelegate = new DLListDelegate ( downloadList ) ;
2006-09-30 20:02:39 +04:00
downloadList - > setItemDelegate ( DLDelegate ) ;
2007-02-24 01:52:24 +03:00
// Hide hash column
downloadList - > hideColumn ( HASH ) ;
2007-05-08 01:20:35 +04:00
2007-07-22 13:47:27 +04:00
connect ( BTSession , SIGNAL ( addedTorrent ( QString , torrent_handle & , bool ) ) , this , SLOT ( torrentAdded ( QString , torrent_handle & , bool ) ) ) ;
connect ( BTSession , SIGNAL ( duplicateTorrent ( QString ) ) , this , SLOT ( torrentDuplicate ( QString ) ) ) ;
connect ( BTSession , SIGNAL ( invalidTorrent ( QString ) ) , this , SLOT ( torrentCorrupted ( QString ) ) ) ;
2007-07-14 16:35:04 +04:00
connect ( BTSession , SIGNAL ( finishedTorrent ( torrent_handle & ) ) , this , SLOT ( finishedTorrent ( torrent_handle & ) ) ) ;
connect ( BTSession , SIGNAL ( fullDiskError ( torrent_handle & ) ) , this , SLOT ( fullDiskError ( torrent_handle & ) ) ) ;
connect ( BTSession , SIGNAL ( portListeningFailure ( ) ) , this , SLOT ( portListeningFailure ( ) ) ) ;
2007-07-22 13:47:27 +04:00
connect ( BTSession , SIGNAL ( trackerError ( QString , QString , QString ) ) , this , SLOT ( trackerError ( QString , QString , QString ) ) ) ;
2007-07-14 16:35:04 +04:00
connect ( BTSession , SIGNAL ( allTorrentsFinishedChecking ( ) ) , this , SLOT ( sortProgressColumnDelayed ( ) ) ) ;
connect ( BTSession , SIGNAL ( trackerAuthenticationRequired ( torrent_handle & ) ) , this , SLOT ( trackerAuthenticationRequired ( torrent_handle & ) ) ) ;
2007-07-22 13:47:27 +04:00
connect ( BTSession , SIGNAL ( peerBlocked ( QString ) ) , this , SLOT ( addLogPeerBlocked ( const QString ) ) ) ;
2007-07-24 11:30:33 +04:00
connect ( BTSession , SIGNAL ( fastResumeDataRejected ( QString ) ) , this , SLOT ( addFastResumeRejectedAlert ( QString ) ) ) ;
2007-07-14 16:35:04 +04:00
connect ( BTSession , SIGNAL ( scanDirFoundTorrents ( const QStringList & ) ) , this , SLOT ( processScannedFiles ( const QStringList & ) ) ) ;
2007-07-22 13:47:27 +04:00
connect ( BTSession , SIGNAL ( newDownloadedTorrent ( QString , QString ) ) , this , SLOT ( processDownloadedFiles ( QString , QString ) ) ) ;
connect ( BTSession , SIGNAL ( downloadFromUrlFailure ( QString , QString ) ) , this , SLOT ( handleDownloadFromUrlFailure ( QString , QString ) ) ) ;
connect ( BTSession , SIGNAL ( aboutToDownloadFromUrl ( QString ) ) , this , SLOT ( displayDownloadingUrlInfos ( QString ) ) ) ;
2006-09-30 20:02:39 +04:00
// creating options
options = new options_imp ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( options , SIGNAL ( status_changed ( QString , bool ) ) , this , SLOT ( OptionsSaved ( QString , bool ) ) ) ;
2006-09-30 20:02:39 +04:00
// Configure BT session according to options
2007-03-10 21:14:53 +03:00
configureSession ( true ) ;
2007-03-30 00:21:17 +04:00
force_exit = false ;
2007-03-08 01:36:01 +03:00
// Resume unfinished torrents
2007-07-14 16:35:04 +04:00
BTSession - > resumeUnfinishedTorrents ( ) ;
2007-05-08 01:20:35 +04:00
// Load last columns width for download list
if ( ! loadColWidthDLList ( ) ) {
downloadList - > header ( ) - > resizeSection ( 0 , 200 ) ;
}
2007-07-22 16:46:03 +04:00
// Search engine tab
searchEngine = new SearchEngine ( BTSession , myTrayIcon , systrayIntegration ) ;
tabs - > addTab ( searchEngine , tr ( " Search " ) ) ;
tabs - > setTabIcon ( 2 , QIcon ( QString : : fromUtf8 ( " :/Icons/skin/search.png " ) ) ) ;
// RSS tab
rssWidget = new RSSImp ( ) ;
tabs - > addTab ( rssWidget , tr ( " RSS " ) ) ;
tabs - > setTabIcon ( 3 , QIcon ( QString : : fromUtf8 ( " :/Icons/rss.png " ) ) ) ;
readSettings ( ) ;
2006-09-30 20:02:39 +04:00
// Add torrent given on command line
2006-10-24 01:42:37 +04:00
processParams ( torrentCmdLine ) ;
2006-09-30 20:02:39 +04:00
// Make download list header clickable for sorting
downloadList - > header ( ) - > setClickable ( true ) ;
downloadList - > header ( ) - > setSortIndicatorShown ( true ) ;
// Connecting Actions to slots
connect ( downloadList , SIGNAL ( doubleClicked ( const QModelIndex & ) ) , this , SLOT ( togglePausedState ( const QModelIndex & ) ) ) ;
connect ( downloadList - > header ( ) , SIGNAL ( sectionPressed ( int ) ) , this , SLOT ( sortDownloadList ( int ) ) ) ;
connect ( downloadList , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayDLListMenu ( const QPoint & ) ) ) ;
2007-04-10 14:54:22 +04:00
// connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayGUIMenu(const QPoint&)));
2006-09-30 20:02:39 +04:00
connect ( infoBar , SIGNAL ( customContextMenuRequested ( const QPoint & ) ) , this , SLOT ( displayInfoBarMenu ( const QPoint & ) ) ) ;
// Use a tcp server to allow only one instance of qBittorrent
2007-03-27 22:49:29 +04:00
tcpServer = new QTcpServer ( ) ;
if ( ! tcpServer - > listen ( QHostAddress : : LocalHost , 1666 ) ) {
2006-10-16 13:02:53 +04:00
std : : cerr < < " Couldn't create socket, single instance mode won't work... \n " ;
2006-09-30 20:02:39 +04:00
}
2007-03-27 22:49:29 +04:00
connect ( tcpServer , SIGNAL ( newConnection ( ) ) , this , SLOT ( acceptConnection ( ) ) ) ;
2006-09-30 20:02:39 +04:00
// Start connection checking timer
checkConnect = new QTimer ( this ) ;
connect ( checkConnect , SIGNAL ( timeout ( ) ) , this , SLOT ( checkConnectionStatus ( ) ) ) ;
checkConnect - > start ( 5000 ) ;
previewProcess = new QProcess ( this ) ;
connect ( previewProcess , SIGNAL ( finished ( int , QProcess : : ExitStatus ) ) , this , SLOT ( cleanTempPreviewFile ( int , QProcess : : ExitStatus ) ) ) ;
2007-07-25 13:03:22 +04:00
// Download list refresher thread
refresher = new DownloadListRefresher ( this ) ;
refresher - > start ( ) ;
2006-09-30 20:02:39 +04:00
// Accept drag 'n drops
setAcceptDrops ( true ) ;
// Set info Bar infos
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " qBittorrent %1 started. " , " e.g: qBittorrent v0.x started. " ) . arg ( QString ( VERSION ) ) ) ;
2007-06-17 22:36:04 +04:00
setInfoBar ( tr ( " Be careful, sharing copyrighted material without permission is against the law. " ) , " red " ) ;
2007-03-10 21:14:53 +03:00
show ( ) ;
2007-07-19 16:58:45 +04:00
createKeyboardShortcuts ( ) ;
2006-09-30 20:02:39 +04:00
qDebug ( " GUI Built " ) ;
}
// Destructor
GUI : : ~ GUI ( ) {
2007-07-14 16:35:04 +04:00
qDebug ( " GUI destruction " ) ;
2007-03-27 22:49:29 +04:00
delete searchEngine ;
2007-04-04 05:36:55 +04:00
delete finishedTorrentTab ;
2006-09-30 20:02:39 +04:00
delete checkConnect ;
delete refresher ;
2007-07-14 16:35:04 +04:00
delete BTSession ;
2007-07-19 16:58:45 +04:00
if ( systrayIntegration ) {
delete myTrayIcon ;
delete myTrayIconMenu ;
}
delete DLDelegate ;
delete DLListModel ;
delete tcpServer ;
previewProcess - > kill ( ) ;
previewProcess - > waitForFinished ( ) ;
delete previewProcess ;
delete connecStatusLblIcon ;
// Keyboard shortcuts
delete switchSearchShortcut ;
delete switchDownShortcut ;
delete switchUpShortcut ;
delete switchRSSShortcut ;
2006-09-30 20:02:39 +04:00
}
2007-07-25 13:03:22 +04:00
int GUI : : getCurrentTab ( ) const {
if ( isHidden ( ) | | isMinimized ( ) ) {
return - 1 ;
} else {
return tabs - > currentIndex ( ) ;
}
}
2007-04-10 11:54:06 +04:00
void GUI : : on_actionWebsite_triggered ( ) {
2006-12-27 06:19:38 +03:00
QDesktopServices : : openUrl ( QUrl ( " http://www.qbittorrent.org " ) ) ;
}
2007-06-17 19:09:00 +04:00
void GUI : : on_actionDocumentation_triggered ( ) {
QDesktopServices : : openUrl ( QUrl ( " http://wiki.qbittorrent.org " ) ) ;
}
2007-04-10 11:54:06 +04:00
void GUI : : on_actionBugReport_triggered ( ) {
2006-12-27 06:19:38 +03:00
QDesktopServices : : openUrl ( QUrl ( " http://bugs.qbittorrent.org " ) ) ;
}
2006-11-14 19:46:05 +03:00
void GUI : : writeSettings ( ) {
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
settings . beginGroup ( " MainWindow " ) ;
settings . setValue ( " size " , size ( ) ) ;
settings . setValue ( " pos " , pos ( ) ) ;
settings . endGroup ( ) ;
}
2007-07-19 16:58:45 +04:00
void GUI : : createKeyboardShortcuts ( ) {
2007-07-20 16:39:20 +04:00
actionCreate_torrent - > setShortcut ( QKeySequence ( " Ctrl+N " ) ) ;
actionOpen - > setShortcut ( QKeySequence ( " Ctrl+O " ) ) ;
actionExit - > setShortcut ( QKeySequence ( " Ctrl+Q " ) ) ;
2007-07-19 16:58:45 +04:00
switchDownShortcut = new QShortcut ( QKeySequence ( tr ( " Alt+1 " , " shortcut to switch to first tab " ) ) , this ) ;
connect ( switchDownShortcut , SIGNAL ( activated ( ) ) , this , SLOT ( displayDownTab ( ) ) ) ;
switchUpShortcut = new QShortcut ( QKeySequence ( tr ( " Alt+2 " , " shortcut to switch to second tab " ) ) , this ) ;
connect ( switchUpShortcut , SIGNAL ( activated ( ) ) , this , SLOT ( displayUpTab ( ) ) ) ;
2007-07-19 17:07:52 +04:00
switchSearchShortcut = new QShortcut ( QKeySequence ( tr ( " Alt+3, Ctrl+F " , " shortcut to switch to third tab (search) " ) ) , this ) ;
2007-07-19 16:58:45 +04:00
connect ( switchSearchShortcut , 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 ( ) ) ) ;
2007-07-20 16:39:20 +04:00
actionTorrent_Properties - > setShortcut ( QKeySequence ( " Alt+P " ) ) ;
actionOptions - > setShortcut ( QKeySequence ( " Alt+O " ) ) ;
actionDelete - > setShortcut ( QKeySequence ( " Del " ) ) ;
actionDelete_Permanently - > setShortcut ( QKeySequence ( " Shift+Del " ) ) ;
actionStart - > setShortcut ( QKeySequence ( " Ctrl+S " ) ) ;
actionStart_All - > setShortcut ( QKeySequence ( " Ctrl+Shift+S " ) ) ;
actionPause - > setShortcut ( QKeySequence ( " Ctrl+P " ) ) ;
actionPause_All - > setShortcut ( QKeySequence ( " Ctrl+Shift+P " ) ) ;
2007-07-19 16:58:45 +04:00
}
// Keyboard shortcuts slots
void GUI : : displayDownTab ( ) {
tabs - > setCurrentIndex ( 0 ) ;
}
void GUI : : displayUpTab ( ) {
tabs - > setCurrentIndex ( 1 ) ;
}
void GUI : : displaySearchTab ( ) {
tabs - > setCurrentIndex ( 2 ) ;
}
void GUI : : displayRSSTab ( ) {
tabs - > setCurrentIndex ( 3 ) ;
}
// End of keyboard shortcuts slots
2006-11-14 19:46:05 +03:00
void GUI : : readSettings ( ) {
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
settings . beginGroup ( " MainWindow " ) ;
resize ( settings . value ( " size " , size ( ) ) . toSize ( ) ) ;
move ( settings . value ( " pos " , screenCenter ( ) ) . toPoint ( ) ) ;
settings . endGroup ( ) ;
}
2007-07-22 13:47:27 +04:00
void GUI : : addLogPeerBlocked ( QString ip ) {
2007-07-04 10:42:36 +04:00
static unsigned short nbLines = 0 ;
+ + nbLines ;
if ( nbLines > 200 ) {
textBlockedUsers - > clear ( ) ;
nbLines = 1 ;
}
2007-07-14 08:22:57 +04:00
textBlockedUsers - > append ( " <font color='grey'> " + QTime : : currentTime ( ) . toString ( " hh:mm:ss " ) + " </font> - " + tr ( " <font color='red'>%1</font> <i>was blocked</i> " , " x.y.z.w was blocked " ) . arg ( ip ) ) ;
2007-07-04 10:42:36 +04:00
}
2006-09-30 20:02:39 +04:00
// Update Info Bar information
2007-07-22 13:47:27 +04:00
void GUI : : setInfoBar ( QString info , QString color ) {
2006-10-29 12:32:28 +03:00
qDebug ( " setInfoBar called " ) ;
2006-09-30 20:02:39 +04:00
static unsigned short nbLines = 0 ;
+ + nbLines ;
// Check log size, clear it if too big
if ( nbLines > 200 ) {
infoBar - > clear ( ) ;
nbLines = 1 ;
}
2006-10-16 23:43:27 +04:00
infoBar - > append ( " <font color='grey'> " + QTime : : currentTime ( ) . toString ( " hh:mm:ss " ) + " </font> - <font color=' " + color + " '><i> " + info + " </i></font> " ) ;
2006-09-30 20:02:39 +04:00
}
2007-07-24 11:30:33 +04:00
void GUI : : addFastResumeRejectedAlert ( QString name ) {
setInfoBar ( tr ( " Fast resume data was rejected for torrent %1 " ) . arg ( name ) ) ;
}
2006-10-19 00:40:40 +04:00
void GUI : : balloonClicked ( ) {
if ( isHidden ( ) ) {
show ( ) ;
if ( isMinimized ( ) ) {
showNormal ( ) ;
}
raise ( ) ;
activateWindow ( ) ;
}
}
2006-09-30 20:02:39 +04:00
2006-12-05 03:27:00 +03:00
void GUI : : acceptConnection ( ) {
2007-03-27 22:49:29 +04:00
clientConnection = tcpServer - > nextPendingConnection ( ) ;
2006-12-05 03:27:00 +03:00
connect ( clientConnection , SIGNAL ( disconnected ( ) ) , this , SLOT ( readParamsOnSocket ( ) ) ) ;
qDebug ( " accepted connection from another instance " ) ;
}
void GUI : : readParamsOnSocket ( ) {
2006-09-30 20:02:39 +04:00
if ( clientConnection ! = 0 ) {
2006-12-05 03:27:00 +03:00
QByteArray params = clientConnection - > readAll ( ) ;
if ( ! params . isEmpty ( ) ) {
processParams ( QString ( params . data ( ) ) . split ( " \n " ) ) ;
qDebug ( " Received parameters from another instance " ) ;
}
2006-09-30 20:02:39 +04:00
}
}
2007-03-08 01:36:01 +03:00
// Toggle paused state of selected torrent
2006-09-30 20:02:39 +04:00
void GUI : : togglePausedState ( const QModelIndex & index ) {
int row = index . row ( ) ;
2007-02-24 01:52:24 +03:00
QString fileHash = DLListModel - > data ( DLListModel - > index ( row , HASH ) ) . toString ( ) ;
2007-07-14 16:35:04 +04:00
if ( BTSession - > isPaused ( fileHash ) ) {
BTSession - > resumeTorrent ( fileHash ) ;
setInfoBar ( tr ( " '%1' resumed. " , " e.g: xxx.avi resumed. " ) . arg ( QString ( BTSession - > getTorrentHandle ( fileHash ) . name ( ) . c_str ( ) ) ) ) ;
2007-04-12 00:50:41 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
2006-09-30 20:02:39 +04:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > pauseTorrent ( fileHash ) ;
2007-04-12 00:50:41 +04:00
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
2007-07-14 16:35:04 +04:00
setInfoBar ( tr ( " '%1' paused. " , " xxx.avi paused. " ) . arg ( QString ( BTSession - > getTorrentHandle ( fileHash ) . name ( ) . c_str ( ) ) ) ) ;
2007-04-12 00:50:41 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QIcon ( " :/Icons/skin/paused.png " ) , Qt : : DecorationRole ) ;
DLListModel - > setData ( DLListModel - > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
setRowColor ( row , " red " ) ;
2006-09-30 20:02:39 +04:00
}
}
2007-04-10 14:05:04 +04:00
void GUI : : on_actionSet_download_limit_triggered ( ) {
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndex index ;
QStringList hashes ;
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file hash
hashes < < DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
}
}
2007-07-14 16:35:04 +04:00
new BandwidthAllocationDialog ( this , false , BTSession , hashes ) ;
2007-04-10 14:05:04 +04:00
}
void GUI : : on_actionSet_upload_limit_triggered ( ) {
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndex index ;
QStringList hashes ;
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file hash
hashes < < DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
}
}
2007-07-14 16:35:04 +04:00
new BandwidthAllocationDialog ( this , true , BTSession , hashes ) ;
2007-04-10 14:05:04 +04:00
}
2007-04-10 13:31:25 +04:00
2007-07-22 13:47:27 +04:00
void GUI : : handleDownloadFromUrlFailure ( QString url , QString reason ) {
2007-07-21 00:18:18 +04:00
// Display a message box
2007-07-21 00:30:33 +04:00
QMessageBox : : critical ( 0 , tr ( " Url download error " ) , tr ( " Couldn't download file at url: %1, reason: %2. " ) . arg ( url ) . arg ( reason ) ) ;
2007-07-21 00:18:18 +04:00
}
2007-07-14 14:50:38 +04:00
void GUI : : on_actionSet_global_upload_limit_triggered ( ) {
qDebug ( " actionSet_global_upload_limit_triggered " ) ;
2007-07-14 16:35:04 +04:00
new BandwidthAllocationDialog ( this , true , BTSession , QStringList ( ) ) ;
2007-07-14 14:50:38 +04:00
}
void GUI : : on_actionSet_global_download_limit_triggered ( ) {
qDebug ( " actionSet_global_download_limit_triggered " ) ;
2007-07-14 16:35:04 +04:00
new BandwidthAllocationDialog ( this , false , BTSession , QStringList ( ) ) ;
2007-07-14 14:50:38 +04:00
}
2007-04-10 11:54:06 +04:00
void GUI : : on_actionPreview_file_triggered ( ) {
2007-04-04 18:36:47 +04:00
if ( tabs - > currentIndex ( ) > 1 ) return ;
bool inDownloadList = true ;
if ( tabs - > currentIndex ( ) ! = 0 )
inDownloadList = false ;
2006-09-30 20:02:39 +04:00
QModelIndex index ;
2007-04-04 18:36:47 +04:00
QModelIndexList selectedIndexes ;
if ( inDownloadList )
selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
else
selectedIndexes = finishedTorrentTab - > getFinishedList ( ) - > selectionModel ( ) - > selectedIndexes ( ) ;
2006-09-30 20:02:39 +04:00
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
2007-04-04 18:36:47 +04:00
// Get the file hash
QString fileHash ;
if ( inDownloadList )
fileHash = DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
else
fileHash = finishedTorrentTab - > getFinishedListModel ( ) - > data ( finishedTorrentTab - > getFinishedListModel ( ) - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
2007-07-14 16:35:04 +04:00
torrent_handle h = BTSession - > getTorrentHandle ( fileHash ) ;
2006-09-30 20:02:39 +04:00
previewSelection = new previewSelect ( this , h ) ;
break ;
}
}
}
void GUI : : cleanTempPreviewFile ( int , QProcess : : ExitStatus ) {
QFile : : remove ( QDir : : tempPath ( ) + QDir : : separator ( ) + " qBT_preview.tmp " ) ;
}
void GUI : : displayDLListMenu ( const QPoint & pos ) {
QMenu myDLLlistMenu ( this ) ;
2006-10-24 02:52:26 +04:00
QModelIndex index ;
2006-09-30 20:02:39 +04:00
// Enable/disable pause/start action given the DL state
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QString previewProgram = settings . value ( " Options/Misc/PreviewProgram " , QString ( ) ) . toString ( ) ;
2006-09-30 20:02:39 +04:00
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
// Get the file name
2007-02-24 01:52:24 +03:00
QString fileHash = DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
2006-09-30 20:02:39 +04:00
// Get handle and pause the torrent
2007-07-14 16:35:04 +04:00
torrent_handle h = BTSession - > getTorrentHandle ( fileHash ) ;
2006-09-30 20:02:39 +04:00
if ( h . is_paused ( ) ) {
myDLLlistMenu . addAction ( actionStart ) ;
} else {
myDLLlistMenu . addAction ( actionPause ) ;
}
myDLLlistMenu . addAction ( actionDelete ) ;
2006-10-29 13:17:53 +03:00
myDLLlistMenu . addAction ( actionDelete_Permanently ) ;
2007-04-10 14:05:04 +04:00
myDLLlistMenu . addAction ( actionSet_download_limit ) ;
myDLLlistMenu . addAction ( actionSet_upload_limit ) ;
2006-09-30 20:02:39 +04:00
myDLLlistMenu . addAction ( actionTorrent_Properties ) ;
2007-07-14 16:35:04 +04:00
if ( ! previewProgram . isEmpty ( ) & & BTSession - > isFilePreviewPossible ( fileHash ) & & selectedIndexes . size ( ) < = DLListModel - > columnCount ( ) ) {
2006-09-30 20:02:39 +04:00
myDLLlistMenu . addAction ( actionPreview_file ) ;
}
break ;
}
}
// Call menu
// XXX: why mapToGlobal() is not enough?
myDLLlistMenu . exec ( mapToGlobal ( pos ) + QPoint ( 22 , 180 ) ) ;
}
2007-03-05 00:12:37 +03:00
// Necessary if we want to close the window
// in one time if "close to systray" is enabled
2007-04-10 11:54:06 +04:00
void GUI : : on_actionExit_triggered ( ) {
2007-03-30 00:21:17 +04:00
force_exit = true ;
2007-03-05 00:12:37 +03:00
close ( ) ;
}
2006-09-30 20:02:39 +04:00
void GUI : : displayGUIMenu ( const QPoint & pos ) {
QMenu myGUIMenu ( this ) ;
myGUIMenu . addAction ( actionOpen ) ;
myGUIMenu . addAction ( actionDownload_from_URL ) ;
myGUIMenu . addAction ( actionStart_All ) ;
myGUIMenu . addAction ( actionPause_All ) ;
myGUIMenu . addAction ( actionExit ) ;
myGUIMenu . exec ( mapToGlobal ( pos ) ) ;
}
2007-07-22 13:47:27 +04:00
void GUI : : previewFile ( QString filePath ) {
2006-09-30 20:02:39 +04:00
// Check if there is already one preview running
if ( previewProcess - > state ( ) = = QProcess : : NotRunning ) {
// First copy temporarily
QString tmpPath = QDir : : tempPath ( ) + QDir : : separator ( ) + " qBT_preview.tmp " ;
QFile : : remove ( tmpPath ) ;
QFile : : copy ( filePath , tmpPath ) ;
// Launch program preview
QStringList params ;
params < < tmpPath ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QString previewProgram = settings . value ( " Options/Misc/PreviewProgram " , QString ( ) ) . toString ( ) ;
previewProcess - > start ( previewProgram , params , QIODevice : : ReadOnly ) ;
2006-09-30 20:02:39 +04:00
} else {
QMessageBox : : critical ( 0 , tr ( " Preview process already running " ) , tr ( " There is already another preview process running. \n Please close the other one first. " ) ) ;
}
}
void GUI : : selectGivenRow ( const QModelIndex & index ) {
int row = index . row ( ) ;
2007-04-10 12:05:27 +04:00
unsigned int nbColumns = DLListModel - > columnCount ( ) ;
for ( unsigned int i = 0 ; i < nbColumns ; + + i ) {
2006-09-30 20:02:39 +04:00
downloadList - > selectionModel ( ) - > select ( DLListModel - > index ( row , i ) , QItemSelectionModel : : Select ) ;
}
}
2007-04-10 11:54:06 +04:00
void GUI : : on_actionClearLog_triggered ( ) {
2006-09-30 20:02:39 +04:00
infoBar - > clear ( ) ;
}
void GUI : : displayInfoBarMenu ( const QPoint & pos ) {
// Log Menu
QMenu myLogMenu ( this ) ;
myLogMenu . addAction ( actionClearLog ) ;
// XXX: Why mapToGlobal() is not enough?
myLogMenu . exec ( mapToGlobal ( pos ) + QPoint ( 22 , 383 ) ) ;
}
2007-06-29 02:58:43 +04:00
void GUI : : sortProgressColumnDelayed ( ) {
if ( delayedSorting ) {
sortDownloadListFloat ( PROGRESS , delayedSortingOrder ) ;
qDebug ( " Delayed sorting of progress column " ) ;
delayedSorting = false ;
}
}
2006-09-30 20:02:39 +04:00
// get information from torrent handles and
// update download list accordingly
2006-12-27 06:19:38 +03:00
void GUI : : updateDlList ( bool force ) {
2006-09-30 20:02:39 +04:00
char tmp [ MAX_CHAR_TMP ] ;
char tmp2 [ MAX_CHAR_TMP ] ;
// update global informations
2007-07-14 16:35:04 +04:00
snprintf ( tmp , MAX_CHAR_TMP , " %.1f " , BTSession - > getPayloadUploadRate ( ) / 1024. ) ;
snprintf ( tmp2 , MAX_CHAR_TMP , " %.1f " , BTSession - > getPayloadDownloadRate ( ) / 1024. ) ;
2007-03-29 23:54:45 +04:00
if ( systrayIntegration ) {
myTrayIcon - > setToolTip ( " <b> " + tr ( " qBittorrent " ) + " </b><br> " + tr ( " DL speed: %1 KiB/s " , " e.g: Download speed: 10 KiB/s " ) . arg ( QString ( tmp2 ) ) + " <br> " + tr ( " UP speed: %1 KiB/s " , " e.g: Upload speed: 10 KiB/s " ) . arg ( QString ( tmp ) ) ) ; // tray icon
}
2007-07-25 13:03:22 +04:00
if ( ! force & & getCurrentTab ( ) ) {
2006-09-30 20:02:39 +04:00
// No need to update if qBittorrent DL list is hidden
return ;
}
2007-03-29 01:59:21 +04:00
// qDebug("Updating download list");
2006-09-30 20:02:39 +04:00
LCD_UpSpeed - > display ( tmp ) ; // UP LCD
LCD_DownSpeed - > display ( tmp2 ) ; // DL LCD
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2006-09-30 20:02:39 +04:00
// browse handles
2007-07-14 16:35:04 +04:00
std : : vector < torrent_handle > handles = BTSession - > getTorrentHandles ( ) ;
2007-04-04 16:01:32 +04:00
QStringList finishedSHAs = finishedTorrentTab - > getFinishedSHAs ( ) ;
2007-04-10 12:05:27 +04:00
unsigned int handlesSize = handles . size ( ) ;
for ( unsigned int i = 0 ; i < handlesSize ; + + i ) {
2007-03-08 01:36:01 +03:00
torrent_handle h = handles [ i ] ;
2006-10-16 13:09:58 +04:00
try {
torrent_status torrentStatus = h . status ( ) ;
2007-02-24 01:52:24 +03:00
QString fileHash = QString ( misc : : toString ( h . info_hash ( ) ) . c_str ( ) ) ;
2007-06-29 01:54:07 +04:00
int row = getRowFromHash ( fileHash ) ;
2007-07-14 16:35:04 +04:00
if ( BTSession - > getTorrentsToPauseAfterChecking ( ) . indexOf ( fileHash ) ! = - 1 ) {
2007-06-29 01:54:07 +04:00
// Pause torrent if it finished checking and it is was supposed to be paused.
// This is a trick to see the progress of the pause torrents on startup
if ( torrentStatus . state ! = torrent_status : : checking_files & & torrentStatus . state ! = torrent_status : : queued_for_checking ) {
qDebug ( " Paused torrent finished checking with state: %d " , torrentStatus . state ) ;
DLListModel - > setData ( DLListModel - > index ( row , PROGRESS ) , QVariant ( ( double ) torrentStatus . progress ) ) ;
2007-07-14 14:50:38 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " red " ) ;
2007-07-14 16:35:04 +04:00
BTSession - > pauseTorrent ( fileHash ) ;
2007-06-29 01:54:07 +04:00
continue ;
}
}
2007-07-14 16:35:04 +04:00
if ( delayedSorting & & BTSession - > getUncheckedTorrentsList ( ) . indexOf ( fileHash ) ! = - 1 ) {
2007-06-29 18:23:15 +04:00
if ( torrentStatus . state ! = torrent_status : : checking_files & & torrentStatus . state ! = torrent_status : : queued_for_checking ) {
2007-07-14 16:35:04 +04:00
BTSession - > setTorrentFinishedChecking ( fileHash ) ;
2007-06-29 18:23:15 +04:00
}
}
row = getRowFromHash ( fileHash ) ; // List may have been sorted in the meantime
2007-04-04 16:01:32 +04:00
if ( h . is_paused ( ) ) continue ;
if ( finishedSHAs . indexOf ( fileHash ) ! = - 1 ) continue ;
if ( row = = - 1 ) {
2007-04-15 22:15:22 +04:00
qDebug ( " Info: Could not find filename in download list, adding it... " ) ;
2007-04-15 21:42:43 +04:00
restoreInDownloadList ( h ) ;
row = getRowFromHash ( fileHash ) ;
2007-04-04 16:01:32 +04:00
}
// Parse download state
torrent_info ti = h . get_torrent_info ( ) ;
// Setting download state
switch ( torrentStatus . state ) {
case torrent_status : : finished :
case torrent_status : : seeding :
2007-04-15 01:06:00 +04:00
qDebug ( " Warning: this shouldn't happen, no finished torrents in download tab, moving it " ) ;
finishedTorrent ( h ) ;
continue ;
2007-04-04 16:01:32 +04:00
case torrent_status : : checking_files :
case torrent_status : : queued_for_checking :
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
DLListModel - > setData ( DLListModel - > index ( row , PROGRESS ) , QVariant ( ( double ) torrentStatus . progress ) ) ;
break ;
case torrent_status : : connecting_to_tracker :
if ( torrentStatus . download_payload_rate > 0 ) {
// Display "Downloading" status when connecting if download speed > 0
2007-07-14 16:35:04 +04:00
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) BTSession - > getETA ( fileHash ) ) ) ;
2007-04-04 16:01:32 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/downloading.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " green " ) ;
} else {
2006-09-30 20:02:39 +04:00
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
2007-04-04 16:01:32 +04:00
}
DLListModel - > setData ( DLListModel - > index ( row , PROGRESS ) , QVariant ( ( double ) torrentStatus . progress ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) torrentStatus . download_payload_rate ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) torrentStatus . upload_payload_rate ) ) ;
break ;
case torrent_status : : downloading :
case torrent_status : : downloading_metadata :
if ( torrentStatus . download_payload_rate > 0 ) {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/downloading.png " ) ) , Qt : : DecorationRole ) ;
2007-07-14 16:35:04 +04:00
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) BTSession - > getETA ( fileHash ) ) ) ;
2007-04-04 16:01:32 +04:00
setRowColor ( row , " green " ) ;
} else {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/stalled.png " ) ) , Qt : : DecorationRole ) ;
2006-09-30 20:02:39 +04:00
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
2007-04-04 16:01:32 +04:00
setRowColor ( row , " black " ) ;
}
DLListModel - > setData ( DLListModel - > index ( row , PROGRESS ) , QVariant ( ( double ) torrentStatus . progress ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) torrentStatus . download_payload_rate ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) torrentStatus . upload_payload_rate ) ) ;
break ;
default :
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
2006-09-30 20:02:39 +04:00
}
2007-04-04 16:01:32 +04:00
DLListModel - > setData ( DLListModel - > index ( row , SEEDSLEECH ) , QVariant ( QString ( misc : : toString ( torrentStatus . num_seeds , true ) . c_str ( ) ) + " / " + QString ( misc : : toString ( torrentStatus . num_peers - torrentStatus . num_seeds , true ) . c_str ( ) ) ) ) ;
2007-07-18 11:44:52 +04:00
DLListModel - > setData ( DLListModel - > index ( row , RATIO ) , QVariant ( QString ( misc : : toString ( BTSession - > getRealRatio ( fileHash ) ) . c_str ( ) ) ) ) ;
2006-10-16 13:09:58 +04:00
} catch ( invalid_handle e ) {
continue ;
2006-09-30 20:02:39 +04:00
}
}
2007-03-29 01:59:21 +04:00
// qDebug("Updated Download list");
2006-09-30 20:02:39 +04:00
}
2007-04-15 21:42:43 +04:00
void GUI : : restoreInDownloadList ( torrent_handle h ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-04-15 21:42:43 +04:00
unsigned int row = DLListModel - > rowCount ( ) ;
QString hash = QString ( misc : : toString ( h . info_hash ( ) ) . c_str ( ) ) ;
// Adding torrent to download list
DLListModel - > insertRow ( row ) ;
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( h . name ( ) . c_str ( ) ) ) ;
2007-07-14 16:35:04 +04:00
DLListModel - > setData ( DLListModel - > index ( row , SIZE ) , QVariant ( ( qlonglong ) BTSession - > torrentEffectiveSize ( hash ) ) ) ;
2007-04-15 21:42:43 +04:00
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , HASH ) , QVariant ( hash ) ) ;
// Pause torrent if it was paused last time
if ( QFile : : exists ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + hash + " .paused " ) ) {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " red " ) ;
} else {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
}
+ + nbTorrents ;
}
2007-04-04 16:01:32 +04:00
void GUI : : setTabText ( int index , QString text ) {
tabs - > setTabText ( index , text ) ;
}
2006-09-30 20:02:39 +04:00
void GUI : : sortDownloadListFloat ( int index , Qt : : SortOrder sortOrder ) {
QList < QPair < int , double > > lines ;
// insertion sorting
2007-04-10 12:05:27 +04:00
unsigned int nbRows = DLListModel - > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
2006-09-30 20:02:39 +04:00
misc : : insertSort ( lines , QPair < int , double > ( i , DLListModel - > data ( DLListModel - > index ( i , index ) ) . toDouble ( ) ) , sortOrder ) ;
}
// Insert items in new model, in correct order
2007-04-10 12:05:27 +04:00
unsigned int nbRows_old = lines . size ( ) ;
for ( unsigned int row = 0 ; row < nbRows_old ; + + row ) {
2006-09-30 20:02:39 +04:00
DLListModel - > insertRow ( DLListModel - > rowCount ( ) ) ;
2007-04-10 12:05:27 +04:00
unsigned int sourceRow = lines [ row ] . first ;
unsigned int nbColumns = DLListModel - > columnCount ( ) ;
for ( unsigned int col = 0 ; col < nbColumns ; + + col ) {
2006-09-30 20:02:39 +04:00
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) ) ) ;
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) , Qt : : DecorationRole ) , Qt : : DecorationRole ) ;
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) , Qt : : TextColorRole ) , Qt : : TextColorRole ) ;
}
}
// Remove old rows
DLListModel - > removeRows ( 0 , nbRows_old ) ;
}
void GUI : : sortDownloadListString ( int index , Qt : : SortOrder sortOrder ) {
QList < QPair < int , QString > > lines ;
// Insertion sorting
2007-04-10 12:05:27 +04:00
unsigned int nbRows = DLListModel - > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
2006-09-30 20:02:39 +04:00
misc : : insertSortString ( lines , QPair < int , QString > ( i , DLListModel - > data ( DLListModel - > index ( i , index ) ) . toString ( ) ) , sortOrder ) ;
}
// Insert items in new model, in correct order
2007-04-10 12:05:27 +04:00
unsigned int nbRows_old = lines . size ( ) ;
for ( unsigned int row = 0 ; row < nbRows_old ; + + row ) {
2006-09-30 20:02:39 +04:00
DLListModel - > insertRow ( DLListModel - > rowCount ( ) ) ;
2007-04-10 12:05:27 +04:00
unsigned int sourceRow = lines [ row ] . first ;
unsigned int nbColumns = DLListModel - > columnCount ( ) ;
for ( unsigned int col = 0 ; col < nbColumns ; + + col ) {
2006-09-30 20:02:39 +04:00
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) ) ) ;
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) , Qt : : DecorationRole ) , Qt : : DecorationRole ) ;
DLListModel - > setData ( DLListModel - > index ( nbRows_old + row , col ) , DLListModel - > data ( DLListModel - > index ( sourceRow , col ) , Qt : : TextColorRole ) , Qt : : TextColorRole ) ;
}
}
// Remove old rows
DLListModel - > removeRows ( 0 , nbRows_old ) ;
}
2007-05-08 01:20:35 +04:00
void GUI : : sortDownloadList ( int index , Qt : : SortOrder startSortOrder , bool fromLoadColWidth ) {
2007-06-29 01:03:52 +04:00
qDebug ( " Called sort download list " ) ;
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-05-08 01:20:35 +04:00
static Qt : : SortOrder sortOrder = startSortOrder ;
if ( ! fromLoadColWidth & & downloadList - > header ( ) - > sortIndicatorSection ( ) = = index ) {
2006-09-30 20:02:39 +04:00
if ( sortOrder = = Qt : : AscendingOrder ) {
sortOrder = Qt : : DescendingOrder ;
} else {
sortOrder = Qt : : AscendingOrder ;
}
}
2007-06-29 12:14:43 +04:00
QString sortOrderLetter ;
if ( sortOrder = = Qt : : AscendingOrder )
sortOrderLetter = " a " ;
else
sortOrderLetter = " d " ;
if ( fromLoadColWidth ) {
// XXX: Why is this needed?
if ( sortOrder = = Qt : : DescendingOrder )
downloadList - > header ( ) - > setSortIndicator ( index , Qt : : AscendingOrder ) ;
else
downloadList - > header ( ) - > setSortIndicator ( index , Qt : : DescendingOrder ) ;
} else {
downloadList - > header ( ) - > setSortIndicator ( index , sortOrder ) ;
}
2006-09-30 20:02:39 +04:00
switch ( index ) {
case SIZE :
case ETA :
case UPSPEED :
case DLSPEED :
sortDownloadListFloat ( index , sortOrder ) ;
break ;
2007-06-29 02:13:01 +04:00
case PROGRESS :
2007-06-29 12:14:43 +04:00
if ( fromLoadColWidth ) {
// Progress sorting must be delayed until files are checked (on startup)
delayedSorting = true ;
delayedSortingOrder = sortOrder ;
} else {
sortDownloadListFloat ( index , sortOrder ) ;
}
2007-06-29 02:13:01 +04:00
break ;
2006-09-30 20:02:39 +04:00
default :
sortDownloadListString ( index , sortOrder ) ;
}
2007-06-29 19:23:15 +04:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
settings . setValue ( " DownloadListSortedCol " , QString ( misc : : toString ( index ) . c_str ( ) ) + sortOrderLetter ) ;
2006-09-30 20:02:39 +04:00
}
// Toggle Main window visibility
2006-10-18 23:53:54 +04:00
void GUI : : toggleVisibility ( QSystemTrayIcon : : ActivationReason e ) {
if ( e = = QSystemTrayIcon : : Trigger | | e = = QSystemTrayIcon : : DoubleClick ) {
if ( isHidden ( ) ) {
show ( ) ;
if ( isMinimized ( ) ) {
if ( isMaximized ( ) ) {
showMaximized ( ) ;
} else {
showNormal ( ) ;
}
2006-09-30 20:02:39 +04:00
}
2006-10-18 23:53:54 +04:00
raise ( ) ;
activateWindow ( ) ;
} else {
hide ( ) ;
2006-09-30 20:02:39 +04:00
}
}
}
// Center window
2006-11-14 19:46:05 +03:00
QPoint GUI : : screenCenter ( ) {
2006-09-30 20:02:39 +04:00
int scrn = 0 ;
QWidget * w = this - > topLevelWidget ( ) ;
if ( w )
scrn = QApplication : : desktop ( ) - > screenNumber ( w ) ;
else if ( QApplication : : desktop ( ) - > isVirtualDesktop ( ) )
scrn = QApplication : : desktop ( ) - > screenNumber ( QCursor : : pos ( ) ) ;
else
scrn = QApplication : : desktop ( ) - > screenNumber ( this ) ;
QRect desk ( QApplication : : desktop ( ) - > availableGeometry ( scrn ) ) ;
2006-11-14 19:46:05 +03:00
return QPoint ( ( desk . width ( ) - this - > frameGeometry ( ) . width ( ) ) / 2 , ( desk . height ( ) - this - > frameGeometry ( ) . height ( ) ) / 2 ) ;
2006-09-30 20:02:39 +04:00
}
// Save columns width in a file to remember them
// (download list)
void GUI : : saveColWidthDLList ( ) const {
qDebug ( " Saving columns width in download list " ) ;
2006-11-15 00:36:29 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2006-09-30 20:02:39 +04:00
QStringList width_list ;
2007-04-10 12:05:27 +04:00
unsigned int nbColumns = DLListModel - > columnCount ( ) ;
for ( unsigned int i = 0 ; i < nbColumns ; + + i ) {
2006-09-30 20:02:39 +04:00
width_list < < QString ( misc : : toString ( downloadList - > columnWidth ( i ) ) . c_str ( ) ) ;
}
2006-11-15 00:36:29 +03:00
settings . setValue ( " DownloadListColsWidth " , width_list . join ( " " ) ) ;
qDebug ( " Download list columns width saved " ) ;
2006-09-30 20:02:39 +04:00
}
// Load columns width in a file that were saved previously
// (download list)
bool GUI : : loadColWidthDLList ( ) {
2006-11-15 00:36:29 +03:00
qDebug ( " Loading columns width for download list " ) ;
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
QString line = settings . value ( " DownloadListColsWidth " , QString ( ) ) . toString ( ) ;
if ( line . isEmpty ( ) )
return false ;
QStringList width_list = line . split ( ' ' ) ;
if ( width_list . size ( ) ! = DLListModel - > columnCount ( ) )
return false ;
2007-04-10 12:05:27 +04:00
unsigned int listSize = width_list . size ( ) ;
for ( unsigned int i = 0 ; i < listSize ; + + i ) {
2006-09-30 20:02:39 +04:00
downloadList - > header ( ) - > resizeSection ( i , width_list . at ( i ) . toInt ( ) ) ;
}
2007-05-08 01:20:35 +04:00
// Loading last sorted column
QString sortedCol = settings . value ( " DownloadListSortedCol " , QString ( ) ) . toString ( ) ;
if ( ! sortedCol . isEmpty ( ) ) {
Qt : : SortOrder sortOrder ;
if ( sortedCol . endsWith ( " d " ) )
sortOrder = Qt : : DescendingOrder ;
else
sortOrder = Qt : : AscendingOrder ;
sortedCol = sortedCol . left ( sortedCol . size ( ) - 1 ) ;
int index = sortedCol . toInt ( ) ;
sortDownloadList ( index , sortOrder , true ) ;
}
2006-11-15 00:36:29 +03:00
qDebug ( " Download list columns width loaded " ) ;
return true ;
2006-09-30 20:02:39 +04:00
}
// Display About Dialog
2007-04-10 11:54:06 +04:00
void GUI : : on_actionAbout_triggered ( ) {
2006-09-30 20:02:39 +04:00
//About dialog
aboutdlg = new about ( this ) ;
}
// Called when we close the program
void GUI : : closeEvent ( QCloseEvent * e ) {
2007-07-14 16:35:04 +04:00
qDebug ( " Mainwindow received closeEvent " ) ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2007-03-11 02:34:03 +03:00
bool goToSystrayOnExit = settings . value ( " Options/Misc/Behaviour/GoToSystrayOnExit " , false ) . toBool ( ) ;
2007-03-30 00:21:17 +04:00
if ( ! force_exit & & systrayIntegration & & goToSystrayOnExit & & ! this - > isHidden ( ) ) {
2007-02-24 22:23:10 +03:00
hide ( ) ;
e - > ignore ( ) ;
return ;
}
2007-04-04 04:47:26 +04:00
if ( settings . value ( " Options/Misc/Behaviour/ConfirmOnExit " , true ) . toBool ( ) & & nbTorrents ! = 0 ) {
2007-03-29 22:46:50 +04:00
show ( ) ;
2007-04-04 18:53:00 +04:00
if ( ! isMaximized ( ) )
showNormal ( ) ;
2006-09-30 20:02:39 +04:00
if ( QMessageBox : : question ( this ,
2007-03-09 01:51:52 +03:00
tr ( " Are you sure you want to quit? " ) + " -- " + tr ( " qBittorrent " ) ,
2007-04-04 04:47:26 +04:00
tr ( " The download list is not empty. \n Are you sure you want to quit qBittorrent? " ) ,
2006-09-30 20:02:39 +04:00
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ) {
e - > ignore ( ) ;
return ;
}
}
2007-07-14 14:50:38 +04:00
hide ( ) ;
2007-07-14 16:35:04 +04:00
if ( systrayIntegration ) {
// Hide tray icon
myTrayIcon - > hide ( ) ;
}
2006-09-30 20:02:39 +04:00
// Save DHT entry
2007-07-14 16:35:04 +04:00
BTSession - > saveDHTEntry ( ) ;
2006-09-30 20:02:39 +04:00
// Save window size, columns size
2006-11-14 19:46:05 +03:00
writeSettings ( ) ;
2006-09-30 20:02:39 +04:00
saveColWidthDLList ( ) ;
// Create fast resume data
2007-07-14 16:35:04 +04:00
BTSession - > saveFastResumeData ( ) ;
2006-09-30 20:02:39 +04:00
// Accept exit
e - > accept ( ) ;
2007-07-14 16:35:04 +04:00
qApp - > exit ( ) ;
2006-09-30 20:02:39 +04:00
}
// Display window to create a torrent
2007-04-10 11:54:06 +04:00
void GUI : : on_actionCreate_torrent_triggered ( ) {
2006-09-30 20:02:39 +04:00
createWindow = new createtorrent ( this ) ;
}
// Called when we minimize the program
void GUI : : hideEvent ( QHideEvent * e ) {
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2007-05-08 00:10:23 +04:00
if ( systrayIntegration & & settings . value ( " Options/Misc/Behaviour/GoToSystray " , true ) . toBool ( ) & & ! e - > spontaneous ( ) ) {
2006-09-30 20:02:39 +04:00
// Hide window
hide ( ) ;
}
2006-12-27 06:19:38 +03:00
// Accept hiding
e - > accept ( ) ;
}
2006-09-30 20:02:39 +04:00
// Action executed when a file is dropped
void GUI : : dropEvent ( QDropEvent * event ) {
event - > acceptProposedAction ( ) ;
QStringList files = event - > mimeData ( ) - > text ( ) . split ( ' \n ' ) ;
// Add file to download list
2006-10-24 01:42:37 +04:00
QString file ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
bool useTorrentAdditionDialog = settings . value ( " Options/Misc/TorrentAdditionDialog/Enabled " , true ) . toBool ( ) ;
2006-10-24 01:42:37 +04:00
foreach ( file , files ) {
2007-03-10 21:14:53 +03:00
if ( useTorrentAdditionDialog ) {
2006-10-29 12:32:28 +03:00
torrentAdditionDialog * dialog = new torrentAdditionDialog ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( dialog , SIGNAL ( torrentAddition ( QString , bool , bool , QString ) ) , BTSession , SLOT ( addTorrent ( QString , bool , bool , QString ) ) ) ;
connect ( dialog , SIGNAL ( setInfoBarGUI ( QString , QString ) ) , this , SLOT ( setInfoBar ( QString , QString ) ) ) ;
2006-10-29 12:32:28 +03:00
dialog - > showLoad ( file . trimmed ( ) . replace ( " file:// " , " " ) ) ;
2006-10-24 15:41:28 +04:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > addTorrent ( file . trimmed ( ) . replace ( " file:// " , " " ) ) ;
2006-10-24 15:41:28 +04:00
}
2006-10-24 01:42:37 +04:00
}
2006-09-30 20:02:39 +04:00
}
// Decode if we accept drag 'n drop or not
void GUI : : dragEnterEvent ( QDragEnterEvent * event ) {
if ( event - > mimeData ( ) - > hasFormat ( " text/plain " ) ) {
event - > acceptProposedAction ( ) ;
}
}
/*****************************************************
* *
* Torrent *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Display a dialog to allow user to add
// torrents to download list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionOpen_triggered ( ) {
2006-09-30 20:02:39 +04:00
QStringList pathsList ;
2006-11-15 00:17:51 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2006-09-30 20:02:39 +04:00
// Open File Open Dialog
// Note: it is possible to select more than one file
2007-07-14 16:35:04 +04:00
pathsList = QFileDialog : : getOpenFileNames ( 0 ,
2006-11-15 00:17:51 +03:00
tr ( " Open Torrent Files " ) , settings . value ( " MainWindowLastDir " , QDir : : homePath ( ) ) . toString ( ) ,
2006-09-30 20:02:39 +04:00
tr ( " Torrent Files " ) + " (*.torrent) " ) ;
if ( ! pathsList . empty ( ) ) {
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
bool useTorrentAdditionDialog = settings . value ( " Options/Misc/TorrentAdditionDialog/Enabled " , true ) . toBool ( ) ;
2007-04-10 12:05:27 +04:00
unsigned int listSize = pathsList . size ( ) ;
for ( unsigned int i = 0 ; i < listSize ; + + i ) {
2007-03-10 21:14:53 +03:00
if ( useTorrentAdditionDialog ) {
2006-10-29 12:32:28 +03:00
torrentAdditionDialog * dialog = new torrentAdditionDialog ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( dialog , SIGNAL ( torrentAddition ( QString , bool , bool , QString ) ) , BTSession , SLOT ( addTorrent ( QString , bool , bool , QString ) ) ) ;
connect ( dialog , SIGNAL ( setInfoBarGUI ( QString , QString ) ) , this , SLOT ( setInfoBar ( QString , QString ) ) ) ;
2006-10-29 12:32:28 +03:00
dialog - > showLoad ( pathsList . at ( i ) ) ;
2006-10-24 15:41:28 +04:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > addTorrent ( pathsList . at ( i ) ) ;
2006-10-24 15:41:28 +04:00
}
2006-10-24 01:42:37 +04:00
}
2006-09-30 20:02:39 +04:00
// Save last dir to remember it
2006-11-15 00:17:51 +03:00
QStringList top_dir = pathsList . at ( 0 ) . split ( QDir : : separator ( ) ) ;
top_dir . removeLast ( ) ;
settings . setValue ( " MainWindowLastDir " , top_dir . join ( QDir : : separator ( ) ) ) ;
2006-09-30 20:02:39 +04:00
}
}
2006-10-29 13:17:53 +03:00
// delete from download list AND from hard drive
2007-04-10 11:54:06 +04:00
void GUI : : on_actionDelete_Permanently_triggered ( ) {
2007-04-04 16:33:53 +04:00
if ( tabs - > currentIndex ( ) > 1 ) return ;
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-04-04 16:33:53 +04:00
QModelIndexList selectedIndexes ;
2007-06-17 16:15:04 +04:00
bool inDownloadList ;
2007-04-04 16:33:53 +04:00
if ( tabs - > currentIndex ( ) = = 0 ) {
selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
2007-06-17 16:15:04 +04:00
inDownloadList = true ;
2007-04-04 16:33:53 +04:00
} else {
selectedIndexes = finishedTorrentTab - > getFinishedList ( ) - > selectionModel ( ) - > selectedIndexes ( ) ;
inDownloadList = false ;
}
2006-10-29 13:17:53 +03:00
if ( ! selectedIndexes . isEmpty ( ) ) {
2007-04-04 16:33:53 +04:00
int ret ;
if ( inDownloadList ) {
ret = QMessageBox : : question (
this ,
tr ( " Are you sure? -- qBittorrent " ) ,
tr ( " Are you sure you want to delete the selected item(s) in download list and in hard drive? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
} else {
ret = QMessageBox : : question (
this ,
tr ( " Are you sure? -- qBittorrent " ) ,
tr ( " Are you sure you want to delete the selected item(s) in finished list and in hard drive? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
}
if ( ret = = 0 ) {
2006-10-29 13:17:53 +03:00
//User clicked YES
QModelIndex index ;
QList < QPair < int , QModelIndex > > sortedIndexes ;
// We have to remove items from the bottom
// to the top in order not to change indexes
// of files to delete.
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
qDebug ( " row to delete: %d " , index . row ( ) ) ;
misc : : insertSort2 ( sortedIndexes , QPair < int , QModelIndex > ( index . row ( ) , index ) , Qt : : DescendingOrder ) ;
}
}
QPair < int , QModelIndex > sortedIndex ;
foreach ( sortedIndex , sortedIndexes ) {
qDebug ( " deleting row: %d, %d, col: %d " , sortedIndex . first , sortedIndex . second . row ( ) , sortedIndex . second . column ( ) ) ;
2007-04-04 16:33:53 +04:00
// Get the file name & hash
QString fileName ;
QString fileHash ;
if ( inDownloadList ) {
fileName = DLListModel - > data ( DLListModel - > index ( sortedIndex . second . row ( ) , NAME ) ) . toString ( ) ;
fileHash = DLListModel - > data ( DLListModel - > index ( sortedIndex . second . row ( ) , HASH ) ) . toString ( ) ;
} else {
fileName = finishedTorrentTab - > getFinishedListModel ( ) - > data ( finishedTorrentTab - > getFinishedListModel ( ) - > index ( sortedIndex . second . row ( ) , NAME ) ) . toString ( ) ;
fileHash = finishedTorrentTab - > getFinishedListModel ( ) - > data ( finishedTorrentTab - > getFinishedListModel ( ) - > index ( sortedIndex . second . row ( ) , HASH ) ) . toString ( ) ;
}
2007-03-08 01:36:01 +03:00
// Remove the torrent
2007-07-14 16:35:04 +04:00
BTSession - > deleteTorrent ( fileHash , true ) ;
2007-03-10 19:27:03 +03:00
// Delete item from download list
2007-04-04 16:33:53 +04:00
if ( inDownloadList ) {
DLListModel - > removeRow ( sortedIndex . first ) ;
2006-10-29 13:17:53 +03:00
- - nbTorrents ;
2007-04-04 16:01:32 +04:00
tabs - > setTabText ( 0 , tr ( " Downloads " ) + " ( " + QString ( misc : : toString ( nbTorrents ) . c_str ( ) ) + " ) " ) ;
2007-04-04 16:33:53 +04:00
} else {
finishedTorrentTab - > deleteFromFinishedList ( fileHash ) ;
}
// Update info bar
setInfoBar ( tr ( " '%1' was removed. " , " 'xxx.avi' was removed. " ) . arg ( fileName ) ) ;
2006-10-29 13:17:53 +03:00
}
}
}
2006-09-30 20:02:39 +04:00
}
// delete selected items in the list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionDelete_triggered ( ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-04-04 16:41:47 +04:00
if ( tabs - > currentIndex ( ) > 1 ) return ;
QModelIndexList selectedIndexes ;
bool inDownloadList = true ;
if ( tabs - > currentIndex ( ) = = 0 ) {
selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
} else {
selectedIndexes = finishedTorrentTab - > getFinishedList ( ) - > selectionModel ( ) - > selectedIndexes ( ) ;
inDownloadList = false ;
}
2006-09-30 20:02:39 +04:00
if ( ! selectedIndexes . isEmpty ( ) ) {
2007-04-04 16:41:47 +04:00
int ret ;
if ( inDownloadList ) {
ret = QMessageBox : : question (
this ,
tr ( " Are you sure? -- qBittorrent " ) ,
tr ( " Are you sure you want to delete the selected item(s) in download list? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
} else {
ret = QMessageBox : : question (
this ,
tr ( " Are you sure? -- qBittorrent " ) ,
tr ( " Are you sure you want to delete the selected item(s) in finished list? " ) ,
tr ( " &Yes " ) , tr ( " &No " ) ,
QString ( ) , 0 , 1 ) ;
}
if ( ret = = 0 ) {
2006-09-30 20:02:39 +04:00
//User clicked YES
QModelIndex index ;
2006-10-03 04:11:35 +04:00
QList < QPair < int , QModelIndex > > sortedIndexes ;
// We have to remove items from the bottom
// to the top in order not to change indexes
// of files to delete.
2006-09-30 20:02:39 +04:00
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
2006-10-03 04:11:35 +04:00
qDebug ( " row to delete: %d " , index . row ( ) ) ;
misc : : insertSort2 ( sortedIndexes , QPair < int , QModelIndex > ( index . row ( ) , index ) , Qt : : DescendingOrder ) ;
}
}
QPair < int , QModelIndex > sortedIndex ;
foreach ( sortedIndex , sortedIndexes ) {
qDebug ( " deleting row: %d, %d, col: %d " , sortedIndex . first , sortedIndex . second . row ( ) , sortedIndex . second . column ( ) ) ;
2007-04-04 16:41:47 +04:00
// Get the file name & hash
QString fileName ;
QString fileHash ;
if ( inDownloadList ) {
fileName = DLListModel - > data ( DLListModel - > index ( sortedIndex . second . row ( ) , NAME ) ) . toString ( ) ;
fileHash = DLListModel - > data ( DLListModel - > index ( sortedIndex . second . row ( ) , HASH ) ) . toString ( ) ;
} else {
fileName = finishedTorrentTab - > getFinishedListModel ( ) - > data ( finishedTorrentTab - > getFinishedListModel ( ) - > index ( sortedIndex . second . row ( ) , NAME ) ) . toString ( ) ;
fileHash = finishedTorrentTab - > getFinishedListModel ( ) - > data ( finishedTorrentTab - > getFinishedListModel ( ) - > index ( sortedIndex . second . row ( ) , HASH ) ) . toString ( ) ;
}
2007-03-08 01:36:01 +03:00
// Remove the torrent
2007-07-14 16:35:04 +04:00
BTSession - > deleteTorrent ( fileHash , false ) ;
2007-04-04 16:41:47 +04:00
if ( inDownloadList ) {
// Delete item from download list
DLListModel - > removeRow ( sortedIndex . first ) ;
2006-10-05 23:49:06 +04:00
- - nbTorrents ;
2007-04-04 16:01:32 +04:00
tabs - > setTabText ( 0 , tr ( " Downloads " ) + " ( " + QString ( misc : : toString ( nbTorrents ) . c_str ( ) ) + " ) " ) ;
2007-04-04 16:41:47 +04:00
} else {
finishedTorrentTab - > deleteFromFinishedList ( fileHash ) ;
}
// Update info bar
setInfoBar ( tr ( " '%1' was removed. " , " 'xxx.avi' was removed. " ) . arg ( fileName ) ) ;
2006-09-30 20:02:39 +04:00
}
}
}
}
2007-03-08 01:36:01 +03:00
// Called when a torrent is added
2007-07-22 13:47:27 +04:00
void GUI : : torrentAdded ( QString path , torrent_handle & h , bool fastResume ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-03-08 01:36:01 +03:00
QString hash = QString ( misc : : toString ( h . info_hash ( ) ) . c_str ( ) ) ;
2007-04-04 16:01:32 +04:00
if ( QFile : : exists ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + hash + " .finished " ) ) {
finishedTorrentTab - > addFinishedSHA ( hash ) ;
return ;
}
int row = DLListModel - > rowCount ( ) ;
2007-03-08 01:36:01 +03:00
// Adding torrent to download list
DLListModel - > insertRow ( row ) ;
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( h . name ( ) . c_str ( ) ) ) ;
2007-07-14 16:35:04 +04:00
DLListModel - > setData ( DLListModel - > index ( row , SIZE ) , QVariant ( ( qlonglong ) BTSession - > torrentEffectiveSize ( hash ) ) ) ;
2007-03-08 01:36:01 +03:00
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
2007-07-18 11:44:52 +04:00
DLListModel - > setData ( DLListModel - > index ( row , RATIO ) , QVariant ( QString ( misc : : toString ( BTSession - > getRealRatio ( hash ) ) . c_str ( ) ) ) ) ;
2007-03-08 01:36:01 +03:00
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , HASH ) , QVariant ( hash ) ) ;
// Pause torrent if it was paused last time
if ( QFile : : exists ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + hash + " .paused " ) ) {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " red " ) ;
} else {
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
2006-09-30 20:02:39 +04:00
}
2007-03-08 01:36:01 +03:00
if ( ! fastResume ) {
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " '%1' added to download list. " , " '/home/y/xxx.torrent' was added to download list. " ) . arg ( path ) ) ;
2007-03-08 01:36:01 +03:00
} else {
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " '%1' resumed. (fast resume) " , " '/home/y/xxx.torrent' was resumed. (fast resume) " ) . arg ( path ) ) ;
2006-10-24 01:42:37 +04:00
}
2007-03-08 01:36:01 +03:00
+ + nbTorrents ;
2007-04-04 16:01:32 +04:00
tabs - > setTabText ( 0 , tr ( " Downloads " ) + " ( " + QString ( misc : : toString ( nbTorrents ) . c_str ( ) ) + " ) " ) ;
2006-09-30 20:02:39 +04:00
}
2007-03-08 01:36:01 +03:00
// Called when trying to add a duplicate torrent
2007-07-22 13:47:27 +04:00
void GUI : : torrentDuplicate ( QString path ) {
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " '%1' is already in download list. " , " e.g: 'xxx.avi' is already in download list. " ) . arg ( path ) ) ;
2007-03-08 01:36:01 +03:00
}
2006-09-30 20:02:39 +04:00
2007-07-22 13:47:27 +04:00
void GUI : : torrentCorrupted ( QString path ) {
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " Unable to decode torrent file: '%1' " , " e.g: Unable to decode torrent file: '/home/y/xxx.torrent' " ) . arg ( path ) , " red " ) ;
2007-03-08 01:36:01 +03:00
setInfoBar ( tr ( " This file is either corrupted or this isn't a torrent. " ) , " red " ) ;
2006-09-30 20:02:39 +04:00
}
// As program parameters, we can get paths or urls.
// This function parse the parameters and call
// the right addTorrent function, considering
// the parameter type.
2006-10-24 01:42:37 +04:00
void GUI : : processParams ( const QStringList & params ) {
2006-09-30 20:02:39 +04:00
QString param ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
bool useTorrentAdditionDialog = settings . value ( " Options/Misc/TorrentAdditionDialog/Enabled " , true ) . toBool ( ) ;
2006-09-30 20:02:39 +04:00
foreach ( param , params ) {
param = param . trimmed ( ) ;
if ( param . startsWith ( " http:// " , Qt : : CaseInsensitive ) | | param . startsWith ( " ftp:// " , Qt : : CaseInsensitive ) | | param . startsWith ( " https:// " , Qt : : CaseInsensitive ) ) {
2007-07-14 16:35:04 +04:00
BTSession - > downloadFromUrl ( param ) ;
2006-09-30 20:02:39 +04:00
} else {
2007-03-10 21:14:53 +03:00
if ( useTorrentAdditionDialog ) {
2006-10-29 12:32:28 +03:00
torrentAdditionDialog * dialog = new torrentAdditionDialog ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( dialog , SIGNAL ( torrentAddition ( QString , bool , bool , QString ) ) , BTSession , SLOT ( addTorrent ( QString , bool , bool , QString ) ) ) ;
connect ( dialog , SIGNAL ( setInfoBarGUI ( QString , QString ) ) , this , SLOT ( setInfoBar ( QString , QString ) ) ) ;
2006-10-29 12:32:28 +03:00
dialog - > showLoad ( param ) ;
2006-10-24 15:41:28 +04:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > addTorrent ( param ) ;
2006-10-24 15:41:28 +04:00
}
2006-09-30 20:02:39 +04:00
}
}
}
2007-03-08 01:36:01 +03:00
void GUI : : processScannedFiles ( const QStringList & params ) {
QString param ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
bool useTorrentAdditionDialog = settings . value ( " Options/Misc/TorrentAdditionDialog/Enabled " , true ) . toBool ( ) ;
2007-03-08 01:36:01 +03:00
foreach ( param , params ) {
2007-03-10 21:14:53 +03:00
if ( useTorrentAdditionDialog ) {
2007-03-08 01:36:01 +03:00
torrentAdditionDialog * dialog = new torrentAdditionDialog ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( dialog , SIGNAL ( torrentAddition ( QString , bool , bool , QString ) ) , BTSession , SLOT ( addTorrent ( QString , bool , bool , QString ) ) ) ;
connect ( dialog , SIGNAL ( setInfoBarGUI ( QString , QString ) ) , this , SLOT ( setInfoBar ( QString , QString ) ) ) ;
2007-03-08 01:36:01 +03:00
dialog - > showLoad ( param , true ) ;
} else {
2007-07-14 16:35:04 +04:00
BTSession - > addTorrent ( param , true ) ;
2007-03-08 01:36:01 +03:00
}
}
}
2007-07-22 13:47:27 +04:00
void GUI : : processDownloadedFiles ( QString path , QString url ) {
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
bool useTorrentAdditionDialog = settings . value ( " Options/Misc/TorrentAdditionDialog/Enabled " , true ) . toBool ( ) ;
if ( useTorrentAdditionDialog ) {
2007-03-08 01:36:01 +03:00
torrentAdditionDialog * dialog = new torrentAdditionDialog ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( dialog , SIGNAL ( torrentAddition ( QString , bool , bool , QString ) ) , BTSession , SLOT ( addTorrent ( QString , bool , bool , QString ) ) ) ;
connect ( dialog , SIGNAL ( setInfoBarGUI ( QString , QString ) ) , this , SLOT ( setInfoBar ( QString , QString ) ) ) ;
2007-03-08 01:36:01 +03:00
dialog - > showLoad ( path , false , url ) ;
} else {
2007-07-14 16:35:04 +04:00
BTSession - > addTorrent ( path , false , false , url ) ;
2006-09-30 20:02:39 +04:00
}
}
// Show torrent properties dialog
void GUI : : showProperties ( const QModelIndex & index ) {
int row = index . row ( ) ;
2007-02-24 01:52:24 +03:00
QString fileHash = DLListModel - > data ( DLListModel - > index ( row , HASH ) ) . toString ( ) ;
2007-07-14 16:35:04 +04:00
torrent_handle h = BTSession - > getTorrentHandle ( fileHash ) ;
2007-03-09 01:51:52 +03:00
QStringList errors = trackerErrors . value ( fileHash , QStringList ( tr ( " None " , " i.e: No error message " ) ) ) ;
2007-07-14 16:35:04 +04:00
properties * prop = new properties ( this , BTSession , h , errors ) ;
connect ( prop , SIGNAL ( mustHaveFullAllocationMode ( torrent_handle ) ) , BTSession , SLOT ( reloadTorrent ( torrent_handle ) ) ) ;
2007-07-22 13:47:27 +04:00
connect ( prop , SIGNAL ( filteredFilesChanged ( QString ) ) , this , SLOT ( updateFileSize ( QString ) ) ) ;
2006-09-30 20:02:39 +04:00
prop - > show ( ) ;
}
2007-07-22 13:47:27 +04:00
void GUI : : updateFileSize ( QString hash ) {
2007-04-13 01:28:15 +04:00
int row = getRowFromHash ( hash ) ;
2007-07-14 16:35:04 +04:00
DLListModel - > setData ( DLListModel - > index ( row , SIZE ) , QVariant ( ( qlonglong ) BTSession - > torrentEffectiveSize ( hash ) ) ) ;
2007-04-13 01:28:15 +04:00
}
2006-09-30 20:02:39 +04:00
// Set BT session configuration
2007-03-10 21:14:53 +03:00
void GUI : : configureSession ( bool deleteOptions ) {
2006-09-30 20:02:39 +04:00
qDebug ( " Configuring session " ) ;
QPair < int , int > limits ;
unsigned short old_listenPort , new_listenPort ;
2007-05-02 17:52:29 +04:00
proxy_settings proxySettings ;
session_settings sessionSettings ;
2007-06-16 00:35:07 +04:00
pe_settings encryptionSettings ;
2006-09-30 20:02:39 +04:00
// Configure session regarding options
2007-07-14 16:35:04 +04:00
BTSession - > setDefaultSavePath ( options - > getSavePath ( ) ) ;
old_listenPort = BTSession - > getListenPort ( ) ;
BTSession - > setListeningPortsRange ( options - > getPorts ( ) ) ;
new_listenPort = BTSession - > getListenPort ( ) ;
2007-03-08 01:36:01 +03:00
if ( new_listenPort ! = old_listenPort ) {
2007-03-29 18:31:43 +04:00
setInfoBar ( tr ( " qBittorrent is bind to port: %1 " , " e.g: qBittorrent is bind to port: 1666 " ) . arg ( QString ( misc : : toString ( new_listenPort ) . c_str ( ) ) ) ) ;
2007-03-08 01:36:01 +03:00
}
// Apply max connec limit (-1 if disabled)
2007-07-14 16:35:04 +04:00
BTSession - > setMaxConnections ( options - > getMaxConnec ( ) ) ;
2007-03-08 01:36:01 +03:00
limits = options - > getLimits ( ) ;
switch ( limits . first ) {
case - 1 : // Download limit disabled
case 0 :
2007-07-14 16:35:04 +04:00
BTSession - > setDownloadRateLimit ( - 1 ) ;
2007-03-08 01:36:01 +03:00
break ;
default :
2007-07-14 16:35:04 +04:00
BTSession - > setDownloadRateLimit ( limits . first * 1024 ) ;
2007-03-08 01:36:01 +03:00
}
switch ( limits . second ) {
case - 1 : // Upload limit disabled
case 0 :
2007-07-14 16:35:04 +04:00
BTSession - > setUploadRateLimit ( - 1 ) ;
2007-03-08 01:36:01 +03:00
break ;
default :
2007-07-14 16:35:04 +04:00
BTSession - > setUploadRateLimit ( limits . second * 1024 ) ;
2007-03-08 01:36:01 +03:00
}
// Apply ratio (0 if disabled)
2007-07-14 16:35:04 +04:00
BTSession - > setGlobalRatio ( options - > getRatio ( ) ) ;
2007-03-08 01:36:01 +03:00
// DHT (Trackerless)
if ( options - > isDHTEnabled ( ) ) {
2007-03-29 18:31:43 +04:00
setInfoBar ( tr ( " DHT support [ON], port: %1 " ) . arg ( options - > getDHTPort ( ) ) , " blue " ) ;
2007-07-14 16:35:04 +04:00
BTSession - > enableDHT ( ) ;
2007-03-10 21:20:13 +03:00
// Set DHT Port
2007-07-14 16:35:04 +04:00
BTSession - > setDHTPort ( options - > getDHTPort ( ) ) ;
2007-03-08 01:36:01 +03:00
} else {
2007-03-29 18:31:43 +04:00
setInfoBar ( tr ( " DHT support [OFF] " ) , " blue " ) ;
2007-07-14 16:35:04 +04:00
BTSession - > disableDHT ( ) ;
2007-03-08 01:36:01 +03:00
}
2007-06-16 00:35:07 +04:00
// UPnP can't be disabled
2007-04-12 21:25:47 +04:00
setInfoBar ( tr ( " UPnP support [ON] " ) , " blue " ) ;
2007-06-16 00:35:07 +04:00
// Encryption settings
int encryptionState = options - > getEncryptionSetting ( ) ;
2007-06-16 00:43:31 +04:00
// The most secure, rc4 only so that all streams and encrypted
encryptionSettings . allowed_enc_level = pe_settings : : rc4 ;
2007-06-16 00:35:07 +04:00
encryptionSettings . prefer_rc4 = true ;
switch ( encryptionState ) {
case 0 : //Enabled
encryptionSettings . out_enc_policy = pe_settings : : enabled ;
encryptionSettings . in_enc_policy = pe_settings : : enabled ;
setInfoBar ( tr ( " Encryption support [ON] " ) , " blue " ) ;
break ;
case 1 : // Forced
encryptionSettings . out_enc_policy = pe_settings : : forced ;
encryptionSettings . in_enc_policy = pe_settings : : forced ;
setInfoBar ( tr ( " Encryption support [FORCED] " ) , " blue " ) ;
break ;
default : // Disabled
encryptionSettings . out_enc_policy = pe_settings : : disabled ;
encryptionSettings . in_enc_policy = pe_settings : : disabled ;
setInfoBar ( tr ( " Encryption support [OFF] " ) , " blue " ) ;
}
2007-07-14 16:35:04 +04:00
BTSession - > applyEncryptionSettings ( encryptionSettings ) ;
2007-03-20 00:15:29 +03:00
// PeX
2007-03-08 01:36:01 +03:00
if ( ! options - > isPeXDisabled ( ) ) {
qDebug ( " Enabling Peer eXchange (PeX) " ) ;
2007-03-29 23:54:45 +04:00
setInfoBar ( tr ( " PeX support [ON] " ) , " blue " ) ;
2007-07-14 16:35:04 +04:00
BTSession - > enablePeerExchange ( ) ;
2007-03-08 01:36:01 +03:00
} else {
2007-03-29 18:31:43 +04:00
setInfoBar ( tr ( " PeX support [OFF] " ) , " blue " ) ;
2007-03-08 01:36:01 +03:00
qDebug ( " Peer eXchange (PeX) disabled " ) ;
}
// Apply filtering settings
if ( options - > isFilteringEnabled ( ) ) {
2007-07-14 16:35:04 +04:00
BTSession - > enableIPFilter ( options - > getFilter ( ) ) ;
2007-07-04 10:42:36 +04:00
tabBottom - > setTabEnabled ( 1 , true ) ;
2007-03-08 01:36:01 +03:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > disableIPFilter ( ) ;
2007-07-04 10:42:36 +04:00
tabBottom - > setCurrentIndex ( 0 ) ;
tabBottom - > setTabEnabled ( 1 , false ) ;
2007-03-08 01:36:01 +03:00
}
// Apply Proxy settings
if ( options - > isProxyEnabled ( ) ) {
2007-05-14 00:02:30 +04:00
switch ( options - > getProxyType ( ) ) {
case HTTP_PW :
proxySettings . type = proxy_settings : : http_pw ;
break ;
case SOCKS5 :
proxySettings . type = proxy_settings : : socks5 ;
break ;
case SOCKS5_PW :
proxySettings . type = proxy_settings : : socks5_pw ;
break ;
default :
proxySettings . type = proxy_settings : : http ;
}
2007-05-02 17:52:29 +04:00
proxySettings . hostname = options - > getProxyIp ( ) . toStdString ( ) ;
proxySettings . port = options - > getProxyPort ( ) ;
2007-03-08 01:36:01 +03:00
if ( options - > isProxyAuthEnabled ( ) ) {
2007-05-02 17:52:29 +04:00
proxySettings . username = options - > getProxyUsername ( ) . toStdString ( ) ;
proxySettings . password = options - > getProxyPassword ( ) . toStdString ( ) ;
2007-03-08 01:36:01 +03:00
}
}
2007-07-14 16:35:04 +04:00
BTSession - > setProxySettings ( proxySettings , options - > useProxyForTrackers ( ) , options - > useProxyForPeers ( ) , options - > useProxyForWebseeds ( ) , options - > useProxyForDHT ( ) ) ;
2007-05-02 17:52:29 +04:00
sessionSettings . user_agent = " qBittorrent " VERSION ;
2007-07-14 16:35:04 +04:00
BTSession - > setSessionSettings ( sessionSettings ) ;
2007-03-08 01:36:01 +03:00
// Scan dir stuff
if ( options - > getScanDir ( ) . isNull ( ) ) {
2007-07-14 16:35:04 +04:00
BTSession - > disableDirectoryScanning ( ) ;
2007-03-08 01:36:01 +03:00
} else {
2007-07-14 16:35:04 +04:00
BTSession - > enableDirectoryScanning ( options - > getScanDir ( ) ) ;
2006-09-30 20:02:39 +04:00
}
2007-03-10 21:14:53 +03:00
if ( deleteOptions ) {
delete options ;
}
2006-09-30 20:02:39 +04:00
qDebug ( " Session configured " ) ;
}
2007-03-08 19:40:02 +03:00
// Pause All Downloads in DL list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionPause_All_triggered ( ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-03-08 19:40:02 +03:00
QString fileHash ;
// Pause all torrents
2007-07-14 16:35:04 +04:00
if ( BTSession - > pauseAllTorrents ( ) ) {
2007-06-30 22:56:49 +04:00
// update download list
unsigned int nbRows = DLListModel - > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
fileHash = DLListModel - > data ( DLListModel - > index ( i , HASH ) ) . toString ( ) ;
// Create .paused file
QFile paused_file ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + fileHash + " .paused " ) ;
paused_file . open ( QIODevice : : WriteOnly | QIODevice : : Text ) ;
paused_file . close ( ) ;
// Update DL list items
DLListModel - > setData ( DLListModel - > index ( i , DLSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( i , UPSPEED ) , QVariant ( ( double ) 0. ) ) ;
DLListModel - > setData ( DLListModel - > index ( i , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
DLListModel - > setData ( DLListModel - > index ( i , NAME ) , QVariant ( QIcon ( " :/Icons/skin/paused.png " ) ) , Qt : : DecorationRole ) ;
DLListModel - > setData ( DLListModel - > index ( i , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
setRowColor ( i , " red " ) ;
}
setInfoBar ( tr ( " All downloads were paused. " ) ) ;
2007-03-08 19:40:02 +03:00
}
}
2006-09-30 20:02:39 +04:00
// pause selected items in the list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionPause_triggered ( ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-04-04 18:25:56 +04:00
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
2006-09-30 20:02:39 +04:00
QModelIndex index ;
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
2007-04-04 18:25:56 +04:00
// Get the file name
QString fileHash = DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
2007-07-14 16:35:04 +04:00
if ( ! BTSession - > isPaused ( fileHash ) ) {
2007-03-08 01:36:01 +03:00
// Pause the torrent
2007-07-14 16:35:04 +04:00
BTSession - > pauseTorrent ( fileHash ) ;
2006-09-30 20:02:39 +04:00
// Update DL status
int row = index . row ( ) ;
2007-04-04 18:25:56 +04:00
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
2007-07-14 16:35:04 +04:00
setInfoBar ( tr ( " '%1' paused. " , " xxx.avi paused. " ) . arg ( QString ( BTSession - > getTorrentHandle ( fileHash ) . name ( ) . c_str ( ) ) ) ) ;
2007-04-04 18:25:56 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QIcon ( " :/Icons/skin/paused.png " ) , Qt : : DecorationRole ) ;
DLListModel - > setData ( DLListModel - > index ( row , SEEDSLEECH ) , QVariant ( " 0/0 " ) ) ;
setRowColor ( row , " red " ) ;
2006-09-30 20:02:39 +04:00
}
}
}
}
2007-03-08 19:40:02 +03:00
// Resume All Downloads in DL list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionStart_All_triggered ( ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-03-08 19:40:02 +03:00
QString fileHash ;
// Pause all torrents
2007-07-14 16:35:04 +04:00
if ( BTSession - > resumeAllTorrents ( ) ) {
2007-06-30 22:56:49 +04:00
// update download list
unsigned int nbRows = DLListModel - > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
fileHash = DLListModel - > data ( DLListModel - > index ( i , HASH ) ) . toString ( ) ;
// Remove .paused file
QFile : : remove ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + fileHash + " .paused " ) ;
// Update DL list items
DLListModel - > setData ( DLListModel - > index ( i , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( i , " grey " ) ;
}
setInfoBar ( tr ( " All downloads were resumed. " ) ) ;
2007-03-08 19:40:02 +03:00
}
}
2006-09-30 20:02:39 +04:00
// start selected items in the list
2007-04-10 11:54:06 +04:00
void GUI : : on_actionStart_triggered ( ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-04-04 18:25:56 +04:00
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
2006-09-30 20:02:39 +04:00
QModelIndex index ;
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
2007-04-04 18:25:56 +04:00
// Get the file name
QString fileHash = DLListModel - > data ( DLListModel - > index ( index . row ( ) , HASH ) ) . toString ( ) ;
2007-07-14 16:35:04 +04:00
if ( BTSession - > isPaused ( fileHash ) ) {
2007-03-08 01:36:01 +03:00
// Resume the torrent
2007-07-14 16:35:04 +04:00
BTSession - > resumeTorrent ( fileHash ) ;
2006-09-30 20:02:39 +04:00
// Delete .paused file
2007-02-24 01:52:24 +03:00
QFile : : remove ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + fileHash + " .paused " ) ;
2006-09-30 20:02:39 +04:00
// Update DL status
int row = index . row ( ) ;
2007-07-14 16:35:04 +04:00
setInfoBar ( tr ( " '%1' resumed. " , " e.g: xxx.avi resumed. " ) . arg ( QString ( BTSession - > getTorrentHandle ( fileHash ) . name ( ) . c_str ( ) ) ) ) ;
2007-04-04 18:25:56 +04:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QVariant ( QIcon ( " :/Icons/skin/connecting.png " ) ) , Qt : : DecorationRole ) ;
setRowColor ( row , " grey " ) ;
2006-09-30 20:02:39 +04:00
}
}
}
}
void GUI : : addUnauthenticatedTracker ( QPair < torrent_handle , std : : string > tracker ) {
// Trackers whose authentication was cancelled
if ( unauthenticated_trackers . indexOf ( tracker ) < 0 ) {
unauthenticated_trackers < < tracker ;
}
}
// display properties of selected items
2007-04-10 11:54:06 +04:00
void GUI : : on_actionTorrent_Properties_triggered ( ) {
2007-04-04 16:52:50 +04:00
if ( tabs - > currentIndex ( ) > 1 ) return ;
if ( tabs - > currentIndex ( ) = = 1 ) {
finishedTorrentTab - > propertiesSelection ( ) ;
return ;
}
2006-09-30 20:02:39 +04:00
QModelIndexList selectedIndexes = downloadList - > selectionModel ( ) - > selectedIndexes ( ) ;
QModelIndex index ;
foreach ( index , selectedIndexes ) {
if ( index . column ( ) = = NAME ) {
showProperties ( index ) ;
}
}
}
2007-03-08 01:36:01 +03:00
// called when a torrent has finished
void GUI : : finishedTorrent ( torrent_handle & h ) {
2007-07-25 13:03:22 +04:00
QMutexLocker locker ( & DLListAccess ) ;
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2007-03-08 01:36:01 +03:00
QString fileName = QString ( h . name ( ) . c_str ( ) ) ;
2007-03-11 20:51:53 +03:00
int useOSD = settings . value ( " Options/OSDEnabled " , 1 ) . toInt ( ) ;
2007-04-04 16:01:32 +04:00
// Add it to finished tab
QString hash = QString ( misc : : toString ( h . info_hash ( ) ) . c_str ( ) ) ;
if ( QFile : : exists ( misc : : qBittorrentPath ( ) + " BT_backup " + QDir : : separator ( ) + hash + " .finished " ) ) return ;
2007-04-06 02:29:09 +04:00
setInfoBar ( tr ( " %1 has finished downloading. " , " e.g: xxx.avi has finished downloading. " ) . arg ( fileName ) ) ;
2007-04-04 16:01:32 +04:00
finishedTorrentTab - > addFinishedSHA ( hash ) ;
QList < QStandardItem * > items = DLListModel - > findItems ( hash , Qt : : MatchExactly , HASH ) ;
if ( items . size ( ) ! = 1 ) {
qDebug ( " Problem: Can't delete finished torrent from download list " ) ;
return ;
}
DLListModel - > removeRow ( DLListModel - > indexFromItem ( items . at ( 0 ) ) . row ( ) ) ;
- - nbTorrents ;
tabs - > setTabText ( 0 , tr ( " Downloads " ) + " ( " + QString ( misc : : toString ( nbTorrents ) . c_str ( ) ) + " ) " ) ;
2007-03-29 23:54:45 +04:00
if ( systrayIntegration & & ( useOSD = = 1 | | ( useOSD = = 2 & & ( isMinimized ( ) | | isHidden ( ) ) ) ) ) {
2007-03-09 01:51:52 +03:00
myTrayIcon - > showMessage ( tr ( " Download finished " ) , tr ( " %1 has finished downloading. " , " e.g: xxx.avi has finished downloading. " ) . arg ( fileName ) , QSystemTrayIcon : : Information , TIME_TRAY_BALLOON ) ;
2007-03-08 01:36:01 +03:00
}
}
// Notification when disk is full
void GUI : : fullDiskError ( torrent_handle & h ) {
2007-03-10 21:14:53 +03:00
QSettings settings ( " qBittorrent " , " qBittorrent " ) ;
2007-03-11 20:51:53 +03:00
int useOSD = settings . value ( " Options/OSDEnabled " , 1 ) . toInt ( ) ;
2007-03-29 23:54:45 +04:00
if ( systrayIntegration & & ( useOSD = = 1 | | ( useOSD = = 2 & & ( isMinimized ( ) | | isHidden ( ) ) ) ) ) {
2007-03-09 01:51:52 +03:00
myTrayIcon - > showMessage ( tr ( " I/O Error " , " i.e: Input/Output Error " ) , tr ( " An error occured when trying to read or write %1. The disk is probably full, download has been paused " , " e.g: An error occured when trying to read or write xxx.avi. The disk is probably full, download has been paused " ) . arg ( QString ( h . name ( ) . c_str ( ) ) ) , QSystemTrayIcon : : Critical , TIME_TRAY_BALLOON ) ;
2007-03-08 01:36:01 +03:00
}
// Download will be paused by libtorrent. Updating GUI information accordingly
int row = getRowFromHash ( QString ( misc : : toString ( h . info_hash ( ) ) . c_str ( ) ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , DLSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , UPSPEED ) , QVariant ( ( double ) 0.0 ) ) ;
DLListModel - > setData ( DLListModel - > index ( row , ETA ) , QVariant ( ( qlonglong ) - 1 ) ) ;
2007-03-09 16:46:32 +03:00
setInfoBar ( tr ( " An error occured (full disk?), '%1' paused. " , " e.g: An error occured (full disk?), 'xxx.avi' paused. " ) . arg ( QString ( h . get_torrent_info ( ) . name ( ) . c_str ( ) ) ) ) ;
2007-03-08 01:36:01 +03:00
DLListModel - > setData ( DLListModel - > index ( row , NAME ) , QIcon ( " :/Icons/skin/paused.png " ) , Qt : : DecorationRole ) ;
setRowColor ( row , " red " ) ;
}
// Called when we couldn't listen on any port
// in the given range.
void GUI : : portListeningFailure ( ) {
setInfoBar ( tr ( " Couldn't listen on any of the given ports. " ) , " red " ) ;
}
// Called when we receive an error from tracker
2007-07-22 13:47:27 +04:00
void GUI : : trackerError ( QString hash , QString time , QString msg ) {
2007-03-08 01:36:01 +03:00
// Check trackerErrors list size and clear it if it is too big
if ( trackerErrors . size ( ) > 50 ) {
trackerErrors . clear ( ) ;
}
QStringList errors = trackerErrors . value ( hash , QStringList ( ) ) ;
errors . append ( " <font color='grey'> " + time + " </font> - <font color='red'> " + msg + " </font> " ) ;
trackerErrors . insert ( hash , errors ) ;
}
// Called when a tracker requires authentication
void GUI : : trackerAuthenticationRequired ( torrent_handle & h ) {
if ( unauthenticated_trackers . indexOf ( QPair < torrent_handle , std : : string > ( h , h . status ( ) . current_tracker ) ) < 0 ) {
// Tracker login
new trackerLogin ( this , h ) ;
}
}
2006-09-30 20:02:39 +04:00
// Check connection status and display right icon
void GUI : : checkConnectionStatus ( ) {
2007-03-29 01:59:21 +04:00
// qDebug("Checking connection status");
2006-09-30 20:02:39 +04:00
char tmp [ MAX_CHAR_TMP ] ;
2007-07-14 16:35:04 +04:00
session_status sessionStatus = BTSession - > getSessionStatus ( ) ;
2006-09-30 20:02:39 +04:00
// Update ratio info
float ratio = 1. ;
if ( sessionStatus . total_payload_download ! = 0 ) {
ratio = ( float ) sessionStatus . total_payload_upload / ( float ) sessionStatus . total_payload_download ;
}
if ( ratio > 10. ) {
ratio = 10. ;
}
snprintf ( tmp , MAX_CHAR_TMP , " %.1f " , ratio ) ;
LCD_Ratio - > display ( tmp ) ;
if ( ratio < 0.5 ) {
lbl_ratio_icon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/unhappy.png " ) ) ) ;
} else {
if ( ratio > 1.0 ) {
lbl_ratio_icon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/smile.png " ) ) ) ;
} else {
lbl_ratio_icon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/stare.png " ) ) ) ;
}
}
if ( sessionStatus . has_incoming_connections ) {
// Connection OK
2006-10-23 00:13:35 +04:00
connecStatusLblIcon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/skin/connected.png " ) ) ) ;
2007-03-09 01:51:52 +03:00
connecStatusLblIcon - > setToolTip ( " <b> " + tr ( " Connection Status: " ) + " </b><br> " + tr ( " Online " ) ) ;
2006-09-30 20:02:39 +04:00
} else {
if ( sessionStatus . num_peers ) {
// Firewalled ?
2006-10-23 00:13:35 +04:00
connecStatusLblIcon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/skin/firewalled.png " ) ) ) ;
2007-03-09 01:51:52 +03:00
connecStatusLblIcon - > setToolTip ( " <b> " + tr ( " Connection Status: " ) + " </b><br> " + tr ( " Firewalled? " , " i.e: Behind a firewall/router? " ) + " <br><i> " + tr ( " No incoming connections... " ) + " </i> " ) ;
2006-09-30 20:02:39 +04:00
} else {
// Disconnected
2006-10-23 00:13:35 +04:00
connecStatusLblIcon - > setPixmap ( QPixmap ( QString : : fromUtf8 ( " :/Icons/skin/disconnected.png " ) ) ) ;
2007-03-09 16:46:32 +03:00
connecStatusLblIcon - > setToolTip ( " <b> " + tr ( " Connection status: " ) + " </b><br> " + tr ( " Offline " ) + " <br><i> " + tr ( " No peers found... " ) + " </i> " ) ;
2006-09-30 20:02:39 +04:00
}
}
2007-03-29 01:59:21 +04:00
// qDebug("Connection status updated");
2006-09-30 20:02:39 +04:00
}
/*****************************************************
* *
* Utils *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Set the color of a row in data model
2007-07-22 13:47:27 +04:00
void GUI : : setRowColor ( int row , QString color ) {
2007-04-10 12:05:27 +04:00
unsigned int nbColumns = DLListModel - > columnCount ( ) ;
for ( unsigned int i = 0 ; i < nbColumns ; + + i ) {
2007-03-27 22:49:29 +04:00
DLListModel - > setData ( DLListModel - > index ( row , i ) , QVariant ( QColor ( color ) ) , Qt : : TextColorRole ) ;
2006-09-30 20:02:39 +04:00
}
}
// return the row of in data model
2007-02-24 01:52:24 +03:00
// corresponding to the given the filehash
2007-07-22 13:47:27 +04:00
int GUI : : getRowFromHash ( QString hash ) const {
2007-04-10 12:05:27 +04:00
unsigned int nbRows = DLListModel - > rowCount ( ) ;
for ( unsigned int i = 0 ; i < nbRows ; + + i ) {
2007-02-24 01:52:24 +03:00
if ( DLListModel - > data ( DLListModel - > index ( i , HASH ) ) = = hash ) {
2006-09-30 20:02:39 +04:00
return i ;
}
}
return - 1 ;
}
2007-03-08 20:00:12 +03:00
void GUI : : downloadFromURLList ( const QStringList & urls ) {
2007-07-14 16:35:04 +04:00
BTSession - > downloadFromURLList ( urls ) ;
2007-03-08 20:00:12 +03:00
}
2007-07-22 13:47:27 +04:00
void GUI : : displayDownloadingUrlInfos ( QString url ) {
2007-03-09 01:51:52 +03:00
setInfoBar ( tr ( " Downloading '%1', please wait... " , " e.g: Downloading 'xxx.torrent', please wait... " ) . arg ( url ) , " black " ) ;
2007-03-08 20:00:12 +03:00
}
2006-09-30 20:02:39 +04:00
/*****************************************************
* *
* Options *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-03-29 23:54:45 +04:00
void GUI : : createTrayIcon ( ) {
// Tray icon
myTrayIcon = new QSystemTrayIcon ( QIcon ( " :/Icons/qbittorrent22.png " ) , this ) ;
// Tray icon Menu
myTrayIconMenu = new QMenu ( this ) ;
myTrayIconMenu - > addAction ( actionOpen ) ;
myTrayIconMenu - > addAction ( actionDownload_from_URL ) ;
myTrayIconMenu - > addSeparator ( ) ;
2007-07-14 14:50:38 +04:00
myTrayIconMenu - > addAction ( actionSet_global_download_limit ) ;
myTrayIconMenu - > addAction ( actionSet_global_upload_limit ) ;
myTrayIconMenu - > addSeparator ( ) ;
2007-03-29 23:54:45 +04:00
myTrayIconMenu - > addAction ( actionStart_All ) ;
myTrayIconMenu - > addAction ( actionPause_All ) ;
myTrayIconMenu - > addSeparator ( ) ;
myTrayIconMenu - > addAction ( actionExit ) ;
myTrayIcon - > setContextMenu ( myTrayIconMenu ) ;
connect ( myTrayIcon , SIGNAL ( messageClicked ( ) ) , this , SLOT ( balloonClicked ( ) ) ) ;
// End of Icon Menu
connect ( myTrayIcon , SIGNAL ( activated ( QSystemTrayIcon : : ActivationReason ) ) , this , SLOT ( toggleVisibility ( QSystemTrayIcon : : ActivationReason ) ) ) ;
myTrayIcon - > show ( ) ;
}
2006-09-30 20:02:39 +04:00
// Display Program Options
2007-04-10 11:54:06 +04:00
void GUI : : on_actionOptions_triggered ( ) {
2007-03-10 21:14:53 +03:00
options = new options_imp ( this ) ;
2007-07-22 13:47:27 +04:00
connect ( options , SIGNAL ( status_changed ( QString , bool ) ) , this , SLOT ( OptionsSaved ( QString , bool ) ) ) ;
2006-10-12 20:02:56 +04:00
options - > show ( ) ;
2006-09-30 20:02:39 +04:00
}
// Is executed each time options are saved
2007-07-22 13:47:27 +04:00
void GUI : : OptionsSaved ( QString info , bool deleteOptions ) {
2007-03-29 23:54:45 +04:00
bool newSystrayIntegration = options - > useSystrayIntegration ( ) ;
if ( newSystrayIntegration & & ! systrayIntegration ) {
// create the trayicon
createTrayIcon ( ) ;
}
if ( ! newSystrayIntegration & & systrayIntegration ) {
// Destroy trayicon
delete myTrayIcon ;
delete myTrayIconMenu ;
}
systrayIntegration = newSystrayIntegration ;
2006-09-30 20:02:39 +04:00
// Update info bar
setInfoBar ( info ) ;
// Update session
2007-03-10 21:14:53 +03:00
configureSession ( deleteOptions ) ;
2006-09-30 20:02:39 +04:00
}
/*****************************************************
* *
* HTTP Downloader *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Display an input dialog to prompt user for
// an url
2007-04-10 11:54:06 +04:00
void GUI : : on_actionDownload_from_URL_triggered ( ) {
2006-09-30 20:02:39 +04:00
downloadFromURLDialog = new downloadFromURL ( this ) ;
2007-07-14 16:35:04 +04:00
connect ( downloadFromURLDialog , SIGNAL ( urlsReadyToBeDownloaded ( const QStringList & ) ) , BTSession , SLOT ( downloadFromURLList ( const QStringList & ) ) ) ;
2006-09-30 20:02:39 +04:00
}