2006-09-30 16:02:39 +00:00
|
|
|
/*
|
|
|
|
* Bittorrent Client using Qt4 and libtorrent.
|
2007-07-14 14:31:59 +00:00
|
|
|
* Copyright (C) 2006 Christophe Dumez
|
2006-09-30 16:02:39 +00:00
|
|
|
*
|
2007-07-14 14:31:59 +00: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 16:02:39 +00: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 14:31:59 +00: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 16:02:39 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GUI_H
|
|
|
|
#define GUI_H
|
|
|
|
|
|
|
|
#include <QProcess>
|
2006-10-18 19:53:54 +00:00
|
|
|
#include <QSystemTrayIcon>
|
2008-09-13 07:33:41 +00:00
|
|
|
#include <QPointer>
|
2006-09-30 16:02:39 +00:00
|
|
|
#include "ui_MainWindow.h"
|
2007-08-20 06:29:18 +00:00
|
|
|
#include "qtorrenthandle.h"
|
2007-02-19 16:34:23 +00:00
|
|
|
|
2007-07-23 12:12:55 +00:00
|
|
|
class bittorrent;
|
2006-09-30 16:02:39 +00:00
|
|
|
class createtorrent;
|
|
|
|
class QTimer;
|
2007-08-26 16:25:22 +00:00
|
|
|
class DownloadingTorrents;
|
2007-04-04 01:36:55 +00:00
|
|
|
class FinishedTorrents;
|
2006-09-30 16:02:39 +00:00
|
|
|
class downloadFromURL;
|
2007-03-27 18:49:29 +00:00
|
|
|
class SearchEngine;
|
2008-07-06 18:39:07 +00:00
|
|
|
#ifdef QT_4_4
|
|
|
|
class QLocalServer;
|
|
|
|
class QLocalSocket;
|
|
|
|
#else
|
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
#endif
|
2007-03-27 18:49:29 +00:00
|
|
|
class QCloseEvent;
|
2007-03-29 15:43:08 +00:00
|
|
|
class RSSImp;
|
2007-07-19 12:58:45 +00:00
|
|
|
class QShortcut;
|
2007-07-23 12:46:36 +00:00
|
|
|
class about;
|
|
|
|
class previewSelect;
|
|
|
|
class options_imp;
|
2007-08-26 16:25:22 +00:00
|
|
|
class QTabWidget;
|
|
|
|
class QLabel;
|
|
|
|
class QModelIndex;
|
2008-05-16 07:10:50 +00:00
|
|
|
class HttpServer;
|
2008-07-10 20:19:28 +00:00
|
|
|
class QFrame;
|
2006-09-30 16:02:39 +00:00
|
|
|
|
|
|
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Bittorrent
|
2007-07-14 12:35:04 +00:00
|
|
|
bittorrent *BTSession;
|
2006-09-30 16:02:39 +00:00
|
|
|
QTimer *checkConnect;
|
2007-08-20 06:29:18 +00:00
|
|
|
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers;
|
2006-09-30 16:02:39 +00:00
|
|
|
// GUI related
|
2007-08-26 16:25:22 +00:00
|
|
|
QTabWidget *tabs;
|
2006-09-30 16:02:39 +00:00
|
|
|
options_imp *options;
|
2006-10-18 19:53:54 +00:00
|
|
|
QSystemTrayIcon *myTrayIcon;
|
2008-09-13 07:33:41 +00:00
|
|
|
QPointer<QTimer> systrayCreator;
|
2006-09-30 16:02:39 +00:00
|
|
|
QMenu *myTrayIconMenu;
|
2007-08-26 16:25:22 +00:00
|
|
|
DownloadingTorrents *downloadingTorrentTab;
|
2007-04-04 01:36:55 +00:00
|
|
|
FinishedTorrents *finishedTorrentTab;
|
2006-10-22 20:13:35 +00:00
|
|
|
QLabel *connecStatusLblIcon;
|
2007-03-29 19:54:45 +00:00
|
|
|
bool systrayIntegration;
|
2007-09-09 09:35:30 +00:00
|
|
|
bool displaySpeedInTitle;
|
2007-03-29 20:21:17 +00:00
|
|
|
bool force_exit;
|
2007-09-09 15:46:23 +00:00
|
|
|
unsigned int refreshInterval;
|
2007-08-26 16:25:22 +00:00
|
|
|
QTimer *refresher;
|
2008-07-10 20:19:28 +00:00
|
|
|
QLabel *dlSpeedLbl;
|
|
|
|
QLabel *upSpeedLbl;
|
|
|
|
QLabel *ratioLbl;
|
|
|
|
QLabel *DHTLbl;
|
|
|
|
QFrame *statusSep1;
|
|
|
|
QFrame *statusSep2;
|
|
|
|
QFrame *statusSep3;
|
2008-08-08 13:17:26 +00:00
|
|
|
QFrame *statusSep4;
|
2007-07-19 12:58:45 +00:00
|
|
|
// Keyboard shortcuts
|
|
|
|
QShortcut *switchSearchShortcut;
|
2007-08-18 12:43:21 +00:00
|
|
|
QShortcut *switchSearchShortcut2;
|
2007-07-19 12:58:45 +00:00
|
|
|
QShortcut *switchDownShortcut;
|
|
|
|
QShortcut *switchUpShortcut;
|
|
|
|
QShortcut *switchRSSShortcut;
|
2008-07-19 20:52:49 +00:00
|
|
|
QAction *prioSeparator;
|
2008-08-08 13:17:26 +00:00
|
|
|
QAction *prioSeparator2;
|
2007-03-27 18:49:29 +00:00
|
|
|
// Search
|
|
|
|
SearchEngine *searchEngine;
|
2007-03-29 15:43:08 +00:00
|
|
|
// RSS
|
|
|
|
RSSImp *rssWidget;
|
2008-05-16 07:10:50 +00:00
|
|
|
// Web UI
|
2008-09-13 07:33:41 +00:00
|
|
|
QPointer<HttpServer> httpServer;
|
2007-03-27 18:49:29 +00:00
|
|
|
// Misc
|
2008-07-06 18:39:07 +00:00
|
|
|
#ifdef QT_4_4
|
|
|
|
QLocalServer *localServer;
|
|
|
|
QLocalSocket *clientConnection;
|
|
|
|
#else
|
|
|
|
QTcpServer *localServer;
|
2006-09-30 16:02:39 +00:00
|
|
|
QTcpSocket *clientConnection;
|
2008-07-06 18:39:07 +00:00
|
|
|
#endif
|
2006-09-30 16:02:39 +00:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
// GUI related slots
|
|
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
2006-10-18 19:53:54 +00:00
|
|
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionAbout_triggered();
|
|
|
|
void on_actionCreate_torrent_triggered();
|
2007-08-28 17:03:55 +00:00
|
|
|
void on_actionWebsite_triggered() const;
|
|
|
|
void on_actionBugReport_triggered() const;
|
2008-09-07 12:09:41 +00:00
|
|
|
void on_actionShow_console_triggered();
|
2006-12-05 00:27:00 +00:00
|
|
|
void readParamsOnSocket();
|
|
|
|
void acceptConnection();
|
2007-08-26 16:25:22 +00:00
|
|
|
void togglePausedState(QString hash);
|
2007-11-06 21:11:09 +00:00
|
|
|
void torrentDoubleClicked(QString hash, bool finished);
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionPreview_file_triggered();
|
2007-07-22 09:47:27 +00:00
|
|
|
void previewFile(QString filePath);
|
2006-10-18 20:40:40 +00:00
|
|
|
void balloonClicked();
|
2006-11-14 16:46:05 +00:00
|
|
|
void writeSettings();
|
|
|
|
void readSettings();
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionExit_triggered();
|
2007-03-29 19:54:45 +00:00
|
|
|
void createTrayIcon();
|
2008-07-15 20:19:41 +00:00
|
|
|
void updateUnfinishedTorrentNumberCalc();
|
|
|
|
void updateFinishedTorrentNumberCalc();
|
2007-08-26 16:25:22 +00:00
|
|
|
void updateUnfinishedTorrentNumber(unsigned int nb);
|
|
|
|
void updateFinishedTorrentNumber(unsigned int nb);
|
2007-08-28 17:33:00 +00:00
|
|
|
void fullDiskError(QTorrentHandle& h) const;
|
2007-08-26 16:25:22 +00:00
|
|
|
void handleDownloadFromUrlFailure(QString, QString) const;
|
2008-01-04 20:09:37 +00:00
|
|
|
void createSystrayDelayed();
|
2007-07-19 12:58:45 +00:00
|
|
|
// Keyboard shortcuts
|
|
|
|
void createKeyboardShortcuts();
|
2007-08-28 17:33:00 +00:00
|
|
|
void displayDownTab() const;
|
|
|
|
void displayUpTab() const;
|
|
|
|
void displaySearchTab() const;
|
|
|
|
void displayRSSTab() const;
|
2006-09-30 16:02:39 +00:00
|
|
|
// Torrent actions
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionTorrent_Properties_triggered();
|
|
|
|
void on_actionPause_triggered();
|
|
|
|
void on_actionPause_All_triggered();
|
|
|
|
void on_actionStart_triggered();
|
|
|
|
void on_actionStart_All_triggered();
|
|
|
|
void on_actionOpen_triggered();
|
|
|
|
void on_actionDelete_Permanently_triggered();
|
|
|
|
void on_actionDelete_triggered();
|
2007-07-14 10:50:38 +00:00
|
|
|
void on_actionSet_global_upload_limit_triggered();
|
|
|
|
void on_actionSet_global_download_limit_triggered();
|
2007-08-28 17:03:55 +00:00
|
|
|
void on_actionDocumentation_triggered() const;
|
2006-09-30 16:02:39 +00:00
|
|
|
void checkConnectionStatus();
|
2007-03-10 18:14:53 +00:00
|
|
|
void configureSession(bool deleteOptions);
|
2006-10-23 21:42:37 +00:00
|
|
|
void processParams(const QStringList& params);
|
2007-09-04 04:18:51 +00:00
|
|
|
void addTorrent(QString path);
|
2007-08-20 06:29:18 +00:00
|
|
|
void addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker);
|
2007-03-07 22:36:01 +00:00
|
|
|
void processScannedFiles(const QStringList& params);
|
2007-07-22 09:47:27 +00:00
|
|
|
void processDownloadedFiles(QString path, QString url);
|
2007-03-08 17:00:12 +00:00
|
|
|
void downloadFromURLList(const QStringList& urls);
|
2008-05-16 07:10:50 +00:00
|
|
|
void deleteTorrent(QString hash);
|
2007-08-28 17:33:00 +00:00
|
|
|
void finishedTorrent(QTorrentHandle& h) const;
|
|
|
|
void torrentChecked(QString hash) const;
|
2007-08-26 16:25:22 +00:00
|
|
|
void updateLists();
|
2008-05-16 07:10:50 +00:00
|
|
|
bool initWebUi(QString username, QString password, int port);
|
|
|
|
void pauseTorrent(QString hash);
|
2008-07-14 20:01:21 +00:00
|
|
|
void on_actionIncreasePriority_triggered();
|
|
|
|
void on_actionDecreasePriority_triggered();
|
2006-09-30 16:02:39 +00:00
|
|
|
// Options slots
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionOptions_triggered();
|
2008-09-07 11:31:29 +00:00
|
|
|
void OptionsSaved(bool deleteOptions);
|
2006-09-30 16:02:39 +00:00
|
|
|
// HTTP slots
|
2007-04-10 07:54:06 +00:00
|
|
|
void on_actionDownload_from_URL_triggered();
|
2007-03-29 14:31:43 +00:00
|
|
|
|
2006-09-30 16:02:39 +00:00
|
|
|
|
|
|
|
public slots:
|
2007-08-20 06:29:18 +00:00
|
|
|
void trackerAuthenticationRequired(QTorrentHandle& h);
|
2007-08-28 17:33:00 +00:00
|
|
|
void setTabText(int index, QString text) const;
|
2007-11-16 18:53:21 +00:00
|
|
|
void openDestinationFolder() const;
|
2007-12-07 22:33:19 +00:00
|
|
|
void goBuyPage() const;
|
2008-06-09 19:59:51 +00:00
|
|
|
void updateRatio();
|
2006-09-30 16:02:39 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
2008-08-01 20:03:16 +00:00
|
|
|
bool event(QEvent * event);
|
2008-07-11 17:43:57 +00:00
|
|
|
void displayRSSTab(bool enable);
|
2006-09-30 16:02:39 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Construct / Destruct
|
|
|
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
|
|
|
~GUI();
|
|
|
|
// Methods
|
2007-12-09 15:51:09 +00:00
|
|
|
int getCurrentTabIndex() const;
|
2007-07-30 10:27:56 +00:00
|
|
|
QPoint screenCenter() const;
|
2006-09-30 16:02:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|