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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_H
|
|
|
|
#define GUI_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QProcess>
|
2006-10-18 23:53:54 +04:00
|
|
|
#include <QSystemTrayIcon>
|
2007-06-29 18:00:17 +04:00
|
|
|
#include <QMutex>
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
#include <libtorrent/entry.hpp>
|
|
|
|
#include <libtorrent/bencode.hpp>
|
|
|
|
#include <libtorrent/session.hpp>
|
|
|
|
#include <libtorrent/fingerprint.hpp>
|
|
|
|
#include <libtorrent/session_settings.hpp>
|
|
|
|
#include <libtorrent/identify_client.hpp>
|
|
|
|
#include <libtorrent/alert_types.hpp>
|
|
|
|
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include "options_imp.h"
|
|
|
|
#include "about_imp.h"
|
|
|
|
#include "previewSelect.h"
|
|
|
|
#include "trackerLogin.h"
|
2007-03-05 20:35:38 +03:00
|
|
|
#include "bittorrent.h"
|
2007-02-19 19:34:23 +03:00
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
class createtorrent;
|
|
|
|
class QTimer;
|
2007-04-04 05:36:55 +04:00
|
|
|
class FinishedTorrents;
|
2006-09-30 20:02:39 +04:00
|
|
|
class DLListDelegate;
|
|
|
|
class downloadThread;
|
|
|
|
class downloadFromURL;
|
2007-03-27 22:49:29 +04:00
|
|
|
class SearchEngine;
|
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
class QCloseEvent;
|
2007-03-29 19:43:08 +04:00
|
|
|
class RSSImp;
|
2007-07-19 16:58:45 +04:00
|
|
|
class QShortcut;
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
using namespace libtorrent;
|
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
|
|
|
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2007-04-04 16:52:50 +04:00
|
|
|
public:
|
|
|
|
QHash<QString, QStringList> trackerErrors;
|
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
private:
|
|
|
|
// Bittorrent
|
2007-07-14 16:35:04 +04:00
|
|
|
bittorrent *BTSession;
|
2006-09-30 20:02:39 +04:00
|
|
|
QTimer *checkConnect;
|
|
|
|
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
|
|
|
|
downloadFromURL *downloadFromURLDialog;
|
|
|
|
// GUI related
|
|
|
|
options_imp *options;
|
|
|
|
createtorrent *createWindow;
|
|
|
|
QTimer *refresher;
|
2006-10-18 23:53:54 +04:00
|
|
|
QSystemTrayIcon *myTrayIcon;
|
2006-09-30 20:02:39 +04:00
|
|
|
QMenu *myTrayIconMenu;
|
|
|
|
about *aboutdlg;
|
|
|
|
QStandardItemModel *DLListModel;
|
|
|
|
DLListDelegate *DLDelegate;
|
2007-04-04 05:36:55 +04:00
|
|
|
FinishedTorrents *finishedTorrentTab;
|
2006-10-03 04:11:35 +04:00
|
|
|
unsigned int nbTorrents;
|
2006-10-23 00:13:35 +04:00
|
|
|
QLabel *connecStatusLblIcon;
|
2007-03-29 23:54:45 +04:00
|
|
|
bool systrayIntegration;
|
2007-03-30 00:21:17 +04:00
|
|
|
bool force_exit;
|
2007-06-29 02:13:01 +04:00
|
|
|
bool delayedSorting;
|
|
|
|
Qt::SortOrder delayedSortingOrder;
|
2007-06-29 18:00:17 +04:00
|
|
|
QMutex DLListAccess;
|
2007-07-19 16:58:45 +04:00
|
|
|
// Keyboard shortcuts
|
|
|
|
QShortcut *createShortcut;
|
|
|
|
QShortcut *openShortcut;
|
|
|
|
QShortcut *quitShortcut;
|
|
|
|
QShortcut *switchSearchShortcut;
|
|
|
|
QShortcut *switchDownShortcut;
|
|
|
|
QShortcut *switchUpShortcut;
|
|
|
|
QShortcut *switchRSSShortcut;
|
|
|
|
QShortcut *propertiesShortcut;
|
|
|
|
QShortcut *optionsShortcut;
|
|
|
|
QShortcut *delShortcut;
|
|
|
|
QShortcut *delPermShortcut;
|
|
|
|
QShortcut *startShortcut;
|
|
|
|
QShortcut *startAllShortcut;
|
|
|
|
QShortcut *pauseShortcut;
|
|
|
|
QShortcut *pauseAllPermShortcut;
|
2006-09-30 20:02:39 +04:00
|
|
|
// Preview
|
|
|
|
previewSelect *previewSelection;
|
|
|
|
QProcess *previewProcess;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Search
|
|
|
|
SearchEngine *searchEngine;
|
2007-03-29 19:43:08 +04:00
|
|
|
// RSS
|
|
|
|
RSSImp *rssWidget;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Misc
|
|
|
|
QTcpServer *tcpServer;
|
2006-09-30 20:02:39 +04:00
|
|
|
QTcpSocket *clientConnection;
|
|
|
|
|
|
|
|
protected slots:
|
|
|
|
// GUI related slots
|
|
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
2006-10-18 23:53:54 +04:00
|
|
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionAbout_triggered();
|
2007-07-22 13:47:27 +04:00
|
|
|
void setInfoBar(QString info, QString color="black");
|
2006-12-27 06:19:38 +03:00
|
|
|
void updateDlList(bool force=false);
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionCreate_torrent_triggered();
|
|
|
|
void on_actionClearLog_triggered();
|
|
|
|
void on_actionWebsite_triggered();
|
|
|
|
void on_actionBugReport_triggered();
|
2006-12-05 03:27:00 +03:00
|
|
|
void readParamsOnSocket();
|
|
|
|
void acceptConnection();
|
2006-09-30 20:02:39 +04:00
|
|
|
void saveColWidthDLList() const;
|
|
|
|
bool loadColWidthDLList();
|
2007-05-08 01:20:35 +04:00
|
|
|
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
|
2006-09-30 20:02:39 +04:00
|
|
|
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
|
|
|
|
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
|
|
|
|
void displayDLListMenu(const QPoint& pos);
|
|
|
|
void selectGivenRow(const QModelIndex& index);
|
|
|
|
void togglePausedState(const QModelIndex& index);
|
|
|
|
void displayInfoBarMenu(const QPoint& pos);
|
|
|
|
void displayGUIMenu(const QPoint& pos);
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionPreview_file_triggered();
|
2007-07-22 13:47:27 +04:00
|
|
|
void previewFile(QString filePath);
|
2006-09-30 20:02:39 +04:00
|
|
|
void cleanTempPreviewFile(int, QProcess::ExitStatus);
|
2006-10-19 00:40:40 +04:00
|
|
|
void balloonClicked();
|
2006-11-14 19:46:05 +03:00
|
|
|
void writeSettings();
|
|
|
|
void readSettings();
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionExit_triggered();
|
2007-03-29 23:54:45 +04:00
|
|
|
void createTrayIcon();
|
2007-07-22 13:47:27 +04:00
|
|
|
void addLogPeerBlocked(QString);
|
2007-07-19 16:58:45 +04:00
|
|
|
// Keyboard shortcuts
|
|
|
|
void createKeyboardShortcuts();
|
|
|
|
void displayDownTab();
|
|
|
|
void displayUpTab();
|
|
|
|
void displaySearchTab();
|
|
|
|
void displayRSSTab();
|
2007-07-22 13:47:27 +04:00
|
|
|
void handleDownloadFromUrlFailure(QString, QString);
|
2006-09-30 20:02:39 +04:00
|
|
|
// Torrent actions
|
|
|
|
void showProperties(const QModelIndex &index);
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionTorrent_Properties_triggered();
|
|
|
|
void on_actionPause_triggered();
|
|
|
|
void on_actionPause_All_triggered();
|
2007-04-15 21:42:43 +04:00
|
|
|
void restoreInDownloadList(torrent_handle h);
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionStart_triggered();
|
|
|
|
void on_actionStart_All_triggered();
|
|
|
|
void on_actionOpen_triggered();
|
|
|
|
void on_actionDelete_Permanently_triggered();
|
|
|
|
void on_actionDelete_triggered();
|
2007-04-10 14:05:04 +04:00
|
|
|
void on_actionSet_download_limit_triggered();
|
|
|
|
void on_actionSet_upload_limit_triggered();
|
2007-07-14 14:50:38 +04:00
|
|
|
void on_actionSet_global_upload_limit_triggered();
|
|
|
|
void on_actionSet_global_download_limit_triggered();
|
2007-06-17 19:09:00 +04:00
|
|
|
void on_actionDocumentation_triggered();
|
2006-09-30 20:02:39 +04:00
|
|
|
void checkConnectionStatus();
|
2007-03-10 21:14:53 +03:00
|
|
|
void configureSession(bool deleteOptions);
|
2006-10-24 01:42:37 +04:00
|
|
|
void processParams(const QStringList& params);
|
2006-09-30 20:02:39 +04:00
|
|
|
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
|
2007-03-08 01:36:01 +03:00
|
|
|
void processScannedFiles(const QStringList& params);
|
2007-07-22 13:47:27 +04:00
|
|
|
void processDownloadedFiles(QString path, QString url);
|
2007-03-08 20:00:12 +03:00
|
|
|
void downloadFromURLList(const QStringList& urls);
|
2007-07-22 13:47:27 +04:00
|
|
|
void displayDownloadingUrlInfos(QString url);
|
2006-09-30 20:02:39 +04:00
|
|
|
// Utils slots
|
2007-07-22 13:47:27 +04:00
|
|
|
void setRowColor(int row, QString color);
|
2006-09-30 20:02:39 +04:00
|
|
|
// Options slots
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionOptions_triggered();
|
2007-07-22 13:47:27 +04:00
|
|
|
void OptionsSaved(QString info, bool deleteOptions);
|
2006-09-30 20:02:39 +04:00
|
|
|
// HTTP slots
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionDownload_from_URL_triggered();
|
2007-03-29 18:31:43 +04:00
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
public slots:
|
2007-07-22 13:47:27 +04:00
|
|
|
void torrentAdded(QString path, torrent_handle& h, bool fastResume);
|
|
|
|
void torrentDuplicate(QString path);
|
|
|
|
void torrentCorrupted(QString path);
|
2007-03-08 01:36:01 +03:00
|
|
|
void finishedTorrent(torrent_handle& h);
|
|
|
|
void fullDiskError(torrent_handle& h);
|
|
|
|
void portListeningFailure();
|
2007-07-22 13:47:27 +04:00
|
|
|
void trackerError(QString hash, QString time, QString msg);
|
2007-03-08 01:36:01 +03:00
|
|
|
void trackerAuthenticationRequired(torrent_handle& h);
|
2007-04-04 16:01:32 +04:00
|
|
|
void setTabText(int index, QString text);
|
2007-07-22 13:47:27 +04:00
|
|
|
void updateFileSize(QString hash);
|
2007-06-29 02:58:43 +04:00
|
|
|
void sortProgressColumnDelayed();
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
void hideEvent(QHideEvent *);
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Construct / Destruct
|
|
|
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
|
|
|
~GUI();
|
|
|
|
// Methods
|
2007-07-22 13:47:27 +04:00
|
|
|
int getRowFromHash(QString hash) const;
|
2006-11-14 19:46:05 +03:00
|
|
|
QPoint screenCenter();
|
2006-09-30 20:02:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|