2006-09-30 20:02:39 +04:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Contact : chris@qbittorrent.org
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_H
|
|
|
|
#define GUI_H
|
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QProcess>
|
2006-10-18 23:53:54 +04:00
|
|
|
#include <QSystemTrayIcon>
|
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;
|
|
|
|
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;
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
using namespace libtorrent;
|
|
|
|
namespace fs = boost::filesystem;
|
|
|
|
|
|
|
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Bittorrent
|
2007-03-08 01:36:01 +03:00
|
|
|
bittorrent BTSession;
|
2006-09-30 20:02:39 +04:00
|
|
|
QTimer *checkConnect;
|
2006-12-03 20:27:29 +03:00
|
|
|
QHash<QString, QStringList> trackerErrors;
|
2006-09-30 20:02:39 +04:00
|
|
|
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;
|
2006-10-03 04:11:35 +04:00
|
|
|
unsigned int nbTorrents;
|
2006-10-23 00:13:35 +04:00
|
|
|
QLabel *connecStatusLblIcon;
|
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);
|
2006-09-30 20:02:39 +04:00
|
|
|
void showAbout();
|
|
|
|
void setInfoBar(const QString& info, const QString& color="black");
|
2006-12-27 06:19:38 +03:00
|
|
|
void updateDlList(bool force=false);
|
2006-09-30 20:02:39 +04:00
|
|
|
void showCreateWindow();
|
|
|
|
void clearLog();
|
2006-12-27 06:19:38 +03:00
|
|
|
void openqBTHomepage();
|
|
|
|
void openqBTBugTracker();
|
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();
|
|
|
|
void sortDownloadList(int index);
|
|
|
|
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);
|
|
|
|
void previewFileSelection();
|
|
|
|
void previewFile(const QString& filePath);
|
|
|
|
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-03-05 00:12:37 +03:00
|
|
|
void forceExit();
|
2006-09-30 20:02:39 +04:00
|
|
|
// Torrent actions
|
|
|
|
void showProperties(const QModelIndex &index);
|
|
|
|
void propertiesSelection();
|
|
|
|
void pauseSelection();
|
2007-03-08 19:40:02 +03:00
|
|
|
void pauseAll();
|
2006-09-30 20:02:39 +04:00
|
|
|
void startSelection();
|
2007-03-08 19:40:02 +03:00
|
|
|
void resumeAll();
|
2006-09-30 20:02:39 +04:00
|
|
|
void askForTorrents();
|
2006-10-29 13:17:53 +03:00
|
|
|
void deletePermanently();
|
2006-09-30 20:02:39 +04:00
|
|
|
void deleteSelection();
|
|
|
|
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);
|
|
|
|
void processDownloadedFiles(const QString& path, const QString& url);
|
2007-03-08 20:00:12 +03:00
|
|
|
void downloadFromURLList(const QStringList& urls);
|
|
|
|
void displayDownloadingUrlInfos(const QString& url);
|
2006-09-30 20:02:39 +04:00
|
|
|
// Utils slots
|
2007-03-27 22:49:29 +04:00
|
|
|
void setRowColor(int row, const QString& color);
|
2006-09-30 20:02:39 +04:00
|
|
|
// Options slots
|
2007-03-10 21:14:53 +03:00
|
|
|
void showOptions();
|
|
|
|
void OptionsSaved(const QString& info, bool deleteOptions);
|
2006-09-30 20:02:39 +04:00
|
|
|
// HTTP slots
|
|
|
|
void askForTorrentUrl();
|
2007-03-29 18:31:43 +04:00
|
|
|
#ifndef NO_UPNP
|
|
|
|
void displayNoUPnPWanServiceDetected();
|
2007-03-29 18:49:01 +04:00
|
|
|
void displayUPnPWanServiceDetected();
|
2007-03-29 18:31:43 +04:00
|
|
|
#endif
|
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
public slots:
|
2007-03-08 01:36:01 +03:00
|
|
|
void torrentAdded(const QString& path, torrent_handle& h, bool fastResume);
|
|
|
|
void torrentDuplicate(const QString& path);
|
|
|
|
void torrentCorrupted(const QString& path);
|
|
|
|
void finishedTorrent(torrent_handle& h);
|
|
|
|
void fullDiskError(torrent_handle& h);
|
|
|
|
void portListeningFailure();
|
|
|
|
void trackerError(const QString& hash, const QString& time, const QString& msg);
|
|
|
|
void trackerAuthenticationRequired(torrent_handle& h);
|
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-02-24 01:52:24 +03:00
|
|
|
int getRowFromHash(const QString& name) const;
|
2006-11-14 19:46:05 +03:00
|
|
|
QPoint screenCenter();
|
2006-09-30 20:02:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|