qBittorrent/src/GUI.h

161 lines
5.2 KiB
C
Raw Normal View History

/*
* 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.
*
* 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.
*
* Contact : chris@qbittorrent.org
*/
#ifndef GUI_H
#define GUI_H
#include <QProcess>
#include <QSystemTrayIcon>
2008-09-13 11:33:41 +04:00
#include <QPointer>
2009-11-20 11:20:05 +03:00
#include "ui_mainwindow.h"
#include "qtorrenthandle.h"
class Bittorrent;
class QTimer;
class downloadFromURL;
class SearchEngine;
class QLocalServer;
class QCloseEvent;
class RSSImp;
class QShortcut;
2007-07-23 16:46:36 +04:00
class about;
class options_imp;
class QTabWidget;
class TransferListWidget;
class TransferListFiltersWidget;
class QSplitter;
2009-11-08 17:20:58 +03:00
class PropertiesWidget;
class StatusBar;
class GUI : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
private:
// Bittorrent
Bittorrent *BTSession;
2009-11-18 21:45:06 +03:00
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related
2009-11-18 21:45:06 +03:00
QTimer *guiUpdater;
QTabWidget *tabs;
StatusBar *status_bar;
QPointer<options_imp> options;
2009-11-18 21:45:06 +03:00
QPointer<QSystemTrayIcon> systrayIcon;
2008-09-13 11:33:41 +04:00
QPointer<QTimer> systrayCreator;
QMenu *myTrayIconMenu;
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
2009-11-08 17:20:58 +03:00
PropertiesWidget *properties;
bool displaySpeedInTitle;
bool force_exit;
// Keyboard shortcuts
QShortcut *switchSearchShortcut;
QShortcut *switchSearchShortcut2;
QShortcut *switchTransferShortcut;
QShortcut *switchRSSShortcut;
// Widgets
QAction *prioSeparator;
QAction *prioSeparator2;
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
SearchEngine *searchEngine;
// RSS
2009-11-14 23:39:37 +03:00
QPointer<RSSImp> rssWidget;
// Misc
QLocalServer *localServer;
protected slots:
// GUI related slots
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
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();
void readParamsOnSocket();
void acceptConnection();
void previewFile(QString filePath);
void balloonClicked();
void writeSettings();
void readSettings();
2007-04-10 11:54:06 +04:00
void on_actionExit_triggered();
void createTrayIcon();
void fullDiskError(QTorrentHandle& h, QString msg) const;
void handleDownloadFromUrlFailure(QString, QString) const;
void createSystrayDelayed();
// Keyboard shortcuts
void createKeyboardShortcuts();
void displayTransferTab() const;
2007-08-28 21:33:00 +04:00
void displaySearchTab() const;
void displayRSSTab() const;
// Torrent actions
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;
void on_actionOpen_triggered();
void updateGUI();
void loadPreferences(bool configure_session=true);
void processParams(const QStringList& params);
void addTorrent(QString path);
void addUnauthenticatedTracker(QPair<QTorrentHandle,QString> tracker);
void processDownloadedFiles(QString path, QString url);
void downloadFromURLList(const QStringList& urls);
2007-08-28 21:33:00 +04:00
void finishedTorrent(QTorrentHandle& h) const;
// Options slots
2007-04-10 11:54:06 +04:00
void on_actionOptions_triggered();
void optionsSaved();
// HTTP slots
2007-04-10 11:54:06 +04:00
void on_actionDownload_from_URL_triggered();
2009-03-28 01:25:34 +03:00
public slots:
void trackerAuthenticationRequired(QTorrentHandle& h);
2007-08-28 21:33:00 +04:00
void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const;
protected:
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
bool event(QEvent * event);
void displayRSSTab(bool enable);
public:
// Construct / Destruct
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
2007-12-09 18:51:09 +03:00
int getCurrentTabIndex() const;
QPoint screenCenter() const;
};
#endif