qBittorrent/src/mainwindow.h

213 lines
6.9 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"
2010-10-17 18:46:01 +04:00
class QBtSession;
class downloadFromURL;
class SearchEngine;
class RSSImp;
2007-07-23 16:46:36 +04:00
class about;
class options_imp;
class TransferListWidget;
class TransferListFiltersWidget;
2009-11-08 17:20:58 +03:00
class PropertiesWidget;
class StatusBar;
class consoleDlg;
2010-03-03 17:42:57 +03:00
class about;
2010-10-23 00:13:22 +04:00
class TorrentCreatorDlg;
class downloadFromURL;
2010-06-22 18:18:43 +04:00
class HidableTabWidget;
class LineEdit;
class ExecutionLog;
class PowerManagement;
QT_BEGIN_NAMESPACE
class QCloseEvent;
class QFileSystemWatcher;
class QShortcut;
class QSplitter;
class QTabWidget;
class QTimer;
QT_END_NAMESPACE
2010-11-14 00:15:52 +03:00
class MainWindow : public QMainWindow, private Ui::MainWindow{
Q_OBJECT
2010-03-03 17:48:49 +03:00
public:
// Construct / Destruct
2010-11-14 00:15:52 +03:00
MainWindow(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~MainWindow();
2010-03-03 17:48:49 +03:00
// Methods
QWidget* getCurrentTabWidget() const;
2010-03-03 17:48:49 +03:00
TransferListWidget* getTransferList() const { return transferList; }
QMenu* getTrayIconMenu();
2010-08-18 12:46:04 +04:00
PropertiesWidget *getProperties() const { return properties; }
2010-03-03 17:48:49 +03:00
public slots:
2010-11-24 23:31:14 +03:00
void trackerAuthenticationRequired(const QTorrentHandle& h);
2010-03-03 17:48:49 +03:00
void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const;
void downloadFromURLList(const QStringList& urls);
void updateAltSpeedsBtn(bool alternative);
void updateNbTorrents();
void deleteBTSession();
protected slots:
// GUI related slots
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void toggleVisibility(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
void on_actionAbout_triggered();
void on_actionCreate_torrent_triggered();
void on_actionWebsite_triggered() const;
void on_actionBugReport_triggered() const;
void balloonClicked();
void writeSettings();
void readSettings();
void on_actionExit_triggered();
void createTrayIcon();
2010-11-24 23:31:14 +03:00
void fullDiskError(const QTorrentHandle& h, QString msg) const;
void handleDownloadFromUrlFailure(QString, QString) const;
void createSystrayDelayed();
void tab_changed(int);
void on_actionLock_qBittorrent_triggered();
void defineUILockPassword();
bool unlockUI();
void notifyOfUpdate(QString);
void showConnectionSettings();
void minimizeWindow();
// Keyboard shortcuts
void createKeyboardShortcuts();
void displayTransferTab() const;
void displaySearchTab() const;
void displayRSSTab() const;
// Torrent actions
void on_actionSet_global_upload_limit_triggered();
void on_actionSet_global_download_limit_triggered();
void on_actionDocumentation_triggered() const;
void on_actionOpen_triggered();
void updateGUI();
void loadPreferences(bool configure_session=true);
void processParams(const QString& params);
void processParams(const QStringList& params);
void addTorrent(QString path);
2010-03-03 17:42:57 +03:00
void addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker);
void processDownloadedFiles(QString path, QString url);
2010-11-24 23:31:14 +03:00
void finishedTorrent(const QTorrentHandle& h) const;
void askRecursiveTorrentDownloadConfirmation(const QTorrentHandle &h);
// Options slots
void on_actionOptions_triggered();
void optionsSaved();
// HTTP slots
void on_actionDownload_from_URL_triggered();
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
void handleUpdateCheckFinished(bool update_available, QString new_version);
void handleUpdateInstalled(QString error_msg);
#endif
2009-03-28 01:25:34 +03:00
protected:
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
bool event(QEvent * event);
void displayRSSTab(bool enable);
2010-06-22 17:58:22 +04:00
void displaySearchTab(bool enable);
2011-03-12 23:59:44 +03:00
private:
QIcon getSystrayIcon() const;
2010-03-03 17:48:49 +03:00
private:
QFileSystemWatcher *executable_watcher;
2010-03-03 17:48:49 +03:00
// Bittorrent
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
// GUI related
bool m_posInitialized;
2010-03-03 17:48:49 +03:00
QTimer *guiUpdater;
2010-06-22 18:18:43 +04:00
HidableTabWidget *tabs;
2010-03-03 17:48:49 +03:00
StatusBar *status_bar;
QPointer<options_imp> options;
QPointer<consoleDlg> console;
QPointer<about> aboutDlg;
2010-10-23 00:13:22 +04:00
QPointer<TorrentCreatorDlg> createTorrentDlg;
QPointer<downloadFromURL> downloadFromURLDialog;
2010-03-03 17:48:49 +03:00
QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator;
QPointer<QMenu> myTrayIconMenu;
2010-03-03 17:48:49 +03:00
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
PropertiesWidget *properties;
bool displaySpeedInTitle;
bool force_exit;
bool ui_locked;
LineEdit *search_filter;
2010-03-03 17:48:49 +03:00
// Keyboard shortcuts
QShortcut *switchSearchShortcut;
QShortcut *switchSearchShortcut2;
QShortcut *switchTransferShortcut;
QShortcut *switchRSSShortcut;
// Widgets
QAction *prioSeparator;
2010-12-20 21:22:06 +03:00
QAction *prioSeparatorMenu;
2010-03-03 17:48:49 +03:00
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
2010-06-22 17:58:22 +04:00
QPointer<SearchEngine> searchEngine;
2010-03-03 17:48:49 +03:00
// RSS
QPointer<RSSImp> rssWidget;
// Execution Log
QPointer<ExecutionLog> m_executionLog;
// Power Management
PowerManagement *m_pwr;
QTimer *preventTimer;
2010-06-21 22:32:01 +04:00
private slots:
2010-06-22 17:58:22 +04:00
void on_actionSearch_engine_triggered();
2010-06-22 17:39:49 +04:00
void on_actionRSS_Reader_triggered();
2010-06-21 22:32:01 +04:00
void on_actionSpeed_in_title_bar_triggered();
void on_actionTop_tool_bar_triggered();
void on_action_Import_Torrent_triggered();
2010-10-31 15:03:24 +03:00
void on_actionDonate_money_triggered();
void on_actionExecution_Logs_triggered(bool checked);
void on_actionAutoExit_qBittorrent_toggled(bool );
void on_actionAutoSuspend_system_toggled(bool );
void on_actionAutoShutdown_system_toggled(bool );
// Check for active torrents and set preventing from suspend state
void checkForActiveTorrents();
};
#endif