forked from qbittorrent/qBittorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GUI.h
202 lines (188 loc) · 6.64 KB
/
GUI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
* 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 : [email protected]
*/
#ifndef GUI_H
#define GUI_H
#include <QMainWindow>
#include <QHash>
#include <QProcess>
#include <QTcpServer>
#include <QTcpSocket>
#include <QCloseEvent>
#include <QSystemTrayIcon>
#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"
#include "bittorrent.h"
#define TIME_TRAY_BALLOON 5000
class createtorrent;
class QTimer;
class QCompleter;
class DLListDelegate;
class SearchListDelegate;
class downloadThread;
class downloadFromURL;
using namespace libtorrent;
namespace fs = boost::filesystem;
class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
// Bittorrent
bittorrent BTSession;
QTimer *checkConnect;
QHash<QString, QStringList> trackerErrors;
QList<QPair<torrent_handle,std::string> > unauthenticated_trackers;
downloadFromURL *downloadFromURLDialog;
// GUI related
options_imp *options;
createtorrent *createWindow;
QTimer *refresher;
QSystemTrayIcon *myTrayIcon;
QMenu *myTrayIconMenu;
about *aboutdlg;
QStandardItemModel *DLListModel;
DLListDelegate *DLDelegate;
QStandardItemModel *SearchListModel;
SearchListDelegate *SearchDelegate;
unsigned int nbTorrents;
QLabel *connecStatusLblIcon;
// Preview
previewSelect *previewSelection;
QProcess *previewProcess;
// Search related
QHash<QString, QString> searchResultsUrls;
QProcess *searchProcess;
bool search_stopped;
bool no_search_results;
QByteArray search_result_line_truncated;
unsigned long nb_search_results;
QTcpServer tcpServer;
QTcpSocket *clientConnection;
QCompleter *searchCompleter;
QStringList searchHistory;
protected slots:
// GUI related slots
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
void showAbout();
void setInfoBar(const QString& info, const QString& color="black");
void updateDlList(bool force=false);
void showCreateWindow();
void clearLog();
void openqBTHomepage();
void openqBTBugTracker();
void readParamsOnSocket();
void acceptConnection();
void saveCheckedSearchEngines(int) const;
void saveColWidthDLList() const;
void saveColWidthSearchList() const;
void loadCheckedSearchEngines();
bool loadColWidthDLList();
bool loadColWidthSearchList();
void sortDownloadList(int index);
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
void sortSearchList(int index);
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
void sortSearchListString(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);
void balloonClicked();
void writeSettings();
void readSettings();
void forceExit();
// Torrent actions
void showProperties(const QModelIndex &index);
void propertiesSelection();
void pauseSelection();
void pauseAll();
void startSelection();
void resumeAll();
void askForTorrents();
void deletePermanently();
void deleteSelection();
void checkConnectionStatus();
void configureSession(bool deleteOptions);
void processParams(const QStringList& params);
void addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker);
void processScannedFiles(const QStringList& params);
void processDownloadedFiles(const QString& path, const QString& url);
void downloadFromURLList(const QStringList& urls);
void displayDownloadingUrlInfos(const QString& url);
// Search slots
void on_search_button_clicked();
void on_stop_search_button_clicked();
void on_clear_button_clicked();
void on_download_button_clicked();
void on_update_nova_button_clicked();
void appendSearchResult(const QString& line);
void searchFinished(int exitcode,QProcess::ExitStatus);
void readSearchOutput();
void searchStarted();
void downloadSelectedItem(const QModelIndex& index);
void startSearchHistory();
void saveSearchHistory();
// Utils slots
void setRowColor(int row, const QString& color, bool inDLList=true);
// Options slots
void showOptions();
void OptionsSaved(const QString& info, bool deleteOptions);
// HTTP slots
void askForTorrentUrl();
public slots:
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);
protected:
void closeEvent(QCloseEvent *);
void hideEvent(QHideEvent *);
public:
// Construct / Destruct
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
int getRowFromHash(const QString& name) const;
float getNovaVersion(const QString& novaPath) const;
QByteArray getNovaChangelog(const QString& novaPath) const;
void updateNova() const;
QPoint screenCenter();
};
#endif