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.
|
|
|
|
*
|
2009-04-05 21:00:55 +04:00
|
|
|
* In addition, as a special exception, the copyright holders give permission to
|
|
|
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
|
|
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
|
|
|
* and distribute the linked executables. You must obey the GNU General Public
|
|
|
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
|
|
|
* modify file(s), you may extend this exception to your version of the file(s),
|
|
|
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
* exception statement from your version.
|
|
|
|
*
|
2007-07-14 18:31:59 +04:00
|
|
|
* 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>
|
2008-09-13 11:33:41 +04:00
|
|
|
#include <QPointer>
|
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;
|
|
|
|
class downloadFromURL;
|
2007-03-27 22:49:29 +04:00
|
|
|
class SearchEngine;
|
2009-11-06 17:30:14 +03:00
|
|
|
class QLocalServer;
|
|
|
|
class QLocalSocket;
|
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-07-11 00:19:28 +04:00
|
|
|
class QFrame;
|
2009-11-07 22:55:33 +03:00
|
|
|
class TransferListWidget;
|
2009-11-08 15:05:35 +03:00
|
|
|
class TransferListFiltersWidget;
|
|
|
|
class QSplitter;
|
2009-11-08 17:20:58 +03:00
|
|
|
class PropertiesWidget;
|
2009-11-18 16:18:55 +03:00
|
|
|
class StatusBar;
|
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;
|
2009-11-18 16:18:55 +03:00
|
|
|
QTimer *guiUpdater;
|
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;
|
2009-11-18 16:18:55 +03:00
|
|
|
StatusBar *status_bar;
|
2008-12-24 17:53:40 +03:00
|
|
|
QPointer<options_imp> options;
|
2006-10-18 23:53:54 +04:00
|
|
|
QSystemTrayIcon *myTrayIcon;
|
2008-09-13 11:33:41 +04:00
|
|
|
QPointer<QTimer> systrayCreator;
|
2006-09-30 20:02:39 +04:00
|
|
|
QMenu *myTrayIconMenu;
|
2009-11-07 22:55:33 +03:00
|
|
|
TransferListWidget *transferList;
|
2009-11-08 15:05:35 +03:00
|
|
|
TransferListFiltersWidget *transferListFilters;
|
2009-11-08 17:20:58 +03:00
|
|
|
PropertiesWidget *properties;
|
2009-11-11 19:22:57 +03:00
|
|
|
QSplitter *hSplitter;
|
2009-11-08 15:05:35 +03:00
|
|
|
QSplitter *vSplitter;
|
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;
|
2009-11-07 22:55:33 +03:00
|
|
|
//unsigned int refreshInterval;
|
2007-07-19 16:58:45 +04:00
|
|
|
// Keyboard shortcuts
|
|
|
|
QShortcut *switchSearchShortcut;
|
2007-08-18 16:43:21 +04:00
|
|
|
QShortcut *switchSearchShortcut2;
|
2009-11-18 20:51:50 +03:00
|
|
|
QShortcut *switchTransferShortcut;
|
2007-07-19 16:58:45 +04:00
|
|
|
QShortcut *switchRSSShortcut;
|
2008-12-29 23:01:03 +03:00
|
|
|
QAction *prioSeparator;
|
|
|
|
QAction *prioSeparator2;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Search
|
|
|
|
SearchEngine *searchEngine;
|
2007-03-29 19:43:08 +04:00
|
|
|
// RSS
|
2009-11-14 23:39:37 +03:00
|
|
|
QPointer<RSSImp> rssWidget;
|
2007-03-27 22:49:29 +04:00
|
|
|
// Misc
|
2008-07-06 22:39:07 +04:00
|
|
|
QLocalServer *localServer;
|
|
|
|
QLocalSocket *clientConnection;
|
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;
|
2008-09-07 16:09:41 +04:00
|
|
|
void on_actionShow_console_triggered();
|
2006-12-05 03:27:00 +03:00
|
|
|
void readParamsOnSocket();
|
|
|
|
void acceptConnection();
|
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();
|
2009-04-18 00:04:09 +04:00
|
|
|
void fullDiskError(QTorrentHandle& h, QString msg) 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();
|
2009-11-18 15:40:13 +03:00
|
|
|
void displayTransferTab() const;
|
2007-08-28 21:33:00 +04:00
|
|
|
void displaySearchTab() const;
|
|
|
|
void displayRSSTab() const;
|
2006-09-30 20:02:39 +04:00
|
|
|
// Torrent actions
|
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;
|
2009-11-07 22:55:33 +03:00
|
|
|
void on_actionOpen_triggered();
|
2009-11-18 16:18:55 +03:00
|
|
|
void updateGUI();
|
2009-11-14 22:08:28 +03:00
|
|
|
void loadPreferences(bool configure_session=true);
|
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-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-08-28 21:33:00 +04:00
|
|
|
void finishedTorrent(QTorrentHandle& h) const;
|
2006-09-30 20:02:39 +04:00
|
|
|
// Options slots
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionOptions_triggered();
|
2009-11-15 13:00:07 +03:00
|
|
|
void optionsSaved();
|
2006-09-30 20:02:39 +04:00
|
|
|
// HTTP slots
|
2007-04-10 11:54:06 +04:00
|
|
|
void on_actionDownload_from_URL_triggered();
|
2009-03-28 01:25:34 +03: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;
|
2009-11-07 22:55:33 +03:00
|
|
|
void showNotificationBaloon(QString title, QString msg) const;
|
2006-09-30 20:02:39 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent *);
|
2008-12-27 00:41:09 +03:00
|
|
|
void showEvent(QShowEvent *);
|
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
|