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 <QProcess>
|
2006-10-18 23:53:54 +04:00
|
|
|
#include <QSystemTrayIcon>
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
#include "ui_MainWindow.h"
|
2007-08-20 10:29:18 +04:00
|
|
|
#include "qtorrenthandle.h"
|
2007-02-19 19:34:23 +03:00
|
|
|
|
2007-07-23 16:12:55 +04:00
|
|
|
class bittorrent;
|
2006-09-30 20:02:39 +04:00
|
|
|
class createtorrent;
|
|
|
|
class QTimer;
|
2007-08-26 20:25:22 +04:00
|
|
|
class DownloadingTorrents;
|
2007-04-04 05:36:55 +04:00
|
|
|
class FinishedTorrents;
|
2006-09-30 20:02:39 +04:00
|
|
|
class downloadFromURL;
|
2007-03-27 22:49:29 +04:00
|
|
|
class SearchEngine;
|
2008-07-06 22:39:07 +04:00
|
|
|
#ifdef QT_4_4
|
|
|
|
class QLocalServer;
|
|
|
|
class QLocalSocket;
|
|
|
|
#else
|
|
|
|
class QTcpServer;
|
|
|
|
class QTcpSocket;
|
|
|
|
#endif
|
2007-03-27 22:49:29 +04:00
|
|
|
class QCloseEvent;
|
2007-03-29 19:43:08 +04:00
|
|
|
class RSSImp;
|
2007-07-19 16:58:45 +04:00
|
|
|
class QShortcut;
|
2007-07-23 16:46:36 +04:00
|
|
|
class about;
|
|
|
|
class previewSelect;
|
|
|
|
class options_imp;
|
2007-08-26 20:25:22 +04:00
|
|
|
class QTabWidget;
|
|
|
|
class QLabel;
|
|
|
|
class QModelIndex;
|
2008-05-16 11:10:50 +04:00
|
|
|
class HttpServer;
|
2008-07-11 00:19:28 +04:00
|
|
|
class QFrame;
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Bittorrent
|
2007-07-14 16:35:04 +04:00
|
|
|
bittorrent *BTSession;
|
2006-09-30 20:02:39 +04:00
|
|
|
QTimer *checkConnect;
|
2007-08-20 10:29:18 +04:00
|
|
|
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers;
|
2006-09-30 20:02:39 +04:00
|
|
|
// GUI related
|
2007-08-26 20:25:22 +04:00
|
|
|
QTabWidget *tabs;
|
2006-09-30 20:02:39 +04:00
|
|
|
options_imp *options;
|
2006-10-18 23:53:54 +04:00
|
|
|
QSystemTrayIcon *myTrayIcon;
|
2008-01-04 23:09:37 +03:00
|
|
|
QTimer *systrayCreator;
|
2006-09-30 20:02:39 +04:00
|
|
|
QMenu *myTrayIconMenu;
|
2007-08-26 20:25:22 +04:00
|
|
|
DownloadingTorrents *downloadingTorrentTab;
|
2007-04-04 05:36:55 +04:00
|
|
|
FinishedTorrents *finishedTorrentTab;
|
2006-10-23 00:13:35 +04:00
|
|
|
QLabel *connecStatusLblIcon;
|
2007-03-29 23:54:45 +04:00
|
|
|
bool systrayIntegration;
|
2007-09-09 13:35:30 +04:00
|
|
|
bool displaySpeedInTitle;
|
2007-03-30 00:21:17 +04:00
|
|
|
bool force_exit;
|
2007-09-09 19:46:23 +04:00
|
|
|
unsigned int refreshInterval;
|
2007-08-26 20:25:22 +04:00
|
|
|
QTimer *refresher;
|
2008-07-11 00:19:28 +04:00
|
|
|
QLabel *dlSpeedLbl;
|
|
|
|
QLabel *upSpeedLbl;
|
|
|
|
QLabel *ratioLbl;
|
|
|
|
QLabel *DHTLbl;
|
|
|
|
QFrame *statusSep1;
|
|
|
|
QFrame *statusSep2;
|
|
|
|
QFrame *statusSep3;
|
2008-08-08 17:17:26 +04:00
|
|
|
QFrame *statusSep4;
|
2007-07-19 16:58:45 +04:00
|
|
|
// Keyboard shortcuts
|
|
|
|
QShortcut *switchSearchShortcut;
|
2007-08-18 16:43:21 +04:00
|
|
|
QShortcut *switchSearchShortcut2;
|
2007-07-19 16:58:45 +04:00
|
|
|
QShortcut *switchDownShortcut;
|
|
|
|
QShortcut *switchUpShortcut;
|
|
|
|
QShortcut *switchRSSShortcut;
|
2008-07-20 00:52:49 +04:00
|
|
|
QAction *prioSeparator;
|
2008-08-08 17:17:26 +04:00
|
|
|
QAction *prioSeparator2;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Search
|
|
|
|
SearchEngine *searchEngine;
|
2007-03-29 19:43:08 +04:00
|
|
|
// RSS
|
|
|
|
RSSImp *rssWidget;
|
2008-05-16 11:10:50 +04:00
|
|
|
// Web UI
|
|
|
|
HttpServer *httpServer;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Misc
|
2008-07-06 22:39:07 +04:00
|
|
|
#ifdef QT_4_4
|
|
|
|
QLocalServer *localServer;
|
|
|
|
QLocalSocket *clientConnection;
|
|
|
|
#else
|
|
|
|
QTcpServer *localServer;
|
2006-09-30 20:02:39 +04:00
|
|
|
QTcpSocket *clientConnection;
|
2008-07-06 22:39:07 +04:00
|
|
|
#endif
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
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();
|
|
|
|
void on_actionCreate_torrent_triggered();
|
2007-08-28 21:03:55 +04:00
|
|
|
void on_actionWebsite_triggered() const;
|
|
|
|
void on_actionBugReport_triggered() const;
|
2006-12-05 03:27:00 +03:00
|
|
|
void readParamsOnSocket();
|
|
|
|
void acceptConnection();
|
2007-08-26 20:25:22 +04:00
|
|
|
void togglePausedState(QString hash);
|
2007-11-07 00:11:09 +03:00
|
|
|
void torrentDoubleClicked(QString hash, bool finished);
|
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-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();
|
2008-07-16 00:19:41 +04:00
|
|
|
void updateUnfinishedTorrentNumberCalc();
|
|
|
|
void updateFinishedTorrentNumberCalc();
|
2007-08-26 20:25:22 +04:00
|
|
|
void updateUnfinishedTorrentNumber(unsigned int nb);
|
|
|
|
void updateFinishedTorrentNumber(unsigned int nb);
|
2007-08-28 21:33:00 +04:00
|
|
|
void fullDiskError(QTorrentHandle& h) const;
|
2007-08-26 20:25:22 +04:00
|
|
|
void handleDownloadFromUrlFailure(QString, QString) const;
|
2008-01-04 23:09:37 +03:00
|
|
|
void createSystrayDelayed();
|
2007-07-19 16:58:45 +04:00
|
|
|
// Keyboard shortcuts
|
|
|
|
void createKeyboardShortcuts();
|
2007-08-28 21:33:00 +04:00
|
|
|
void displayDownTab() const;
|
|
|
|
void displayUpTab() const;
|
|
|
|
void displaySearchTab() const;
|
|
|
|
void displayRSSTab() const;
|
2006-09-30 20:02:39 +04:00
|
|
|
// Torrent actions
|
2007-04-10 11:54:06 +04: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 14:50:38 +04:00
|
|
|
void on_actionSet_global_upload_limit_triggered();
|
|
|
|
void on_actionSet_global_download_limit_triggered();
|
2007-08-28 21:03:55 +04:00
|
|
|
void on_actionDocumentation_triggered() const;
|
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);
|
2007-09-04 08:18:51 +04:00
|
|
|
void addTorrent(QString path);
|
2007-08-20 10:29:18 +04:00
|
|
|
void addUnauthenticatedTracker(QPair<QTorrentHandle,QString> 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);
|
2008-05-16 11:10:50 +04:00
|
|
|
void deleteTorrent(QString hash);
|
|
|
|
void deleteRatioTorrent(QString fileName);
|
2007-08-28 21:33:00 +04:00
|
|
|
void finishedTorrent(QTorrentHandle& h) const;
|
|
|
|
void torrentChecked(QString hash) const;
|
2007-08-26 20:25:22 +04:00
|
|
|
void updateLists();
|
2008-05-16 11:10:50 +04:00
|
|
|
bool initWebUi(QString username, QString password, int port);
|
|
|
|
void pauseTorrent(QString hash);
|
2008-07-15 00:01:21 +04:00
|
|
|
void on_actionIncreasePriority_triggered();
|
|
|
|
void on_actionDecreasePriority_triggered();
|
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-08-20 10:29:18 +04:00
|
|
|
void trackerAuthenticationRequired(QTorrentHandle& h);
|
2007-08-28 21:33:00 +04:00
|
|
|
void setTabText(int index, QString text) const;
|
2007-11-16 21:53:21 +03:00
|
|
|
void openDestinationFolder() const;
|
2007-12-08 01:33:19 +03:00
|
|
|
void goBuyPage() const;
|
2008-06-09 23:59:51 +04:00
|
|
|
void updateRatio();
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
2008-08-02 00:03:16 +04:00
|
|
|
bool event(QEvent * event);
|
2008-07-11 21:43:57 +04:00
|
|
|
void displayRSSTab(bool enable);
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Construct / Destruct
|
|
|
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
|
|
|
~GUI();
|
|
|
|
// Methods
|
2007-12-09 18:51:09 +03:00
|
|
|
int getCurrentTabIndex() const;
|
2007-07-30 14:27:56 +04:00
|
|
|
QPoint screenCenter() const;
|
2006-09-30 20:02:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|