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>
|
2009-11-20 11:20:05 +03:00
|
|
|
#include "ui_mainwindow.h"
|
2013-11-17 01:16:24 +04:00
|
|
|
#include "statsdialog.h"
|
2007-02-19 19:34:23 +03:00
|
|
|
|
2006-09-30 20:02:39 +04:00
|
|
|
class downloadFromURL;
|
2015-08-26 20:05:57 +03:00
|
|
|
class SearchWidget;
|
2007-03-29 19:43:08 +04:00
|
|
|
class RSSImp;
|
2007-07-23 16:46:36 +04:00
|
|
|
class about;
|
|
|
|
class options_imp;
|
2009-11-07 22:55:33 +03:00
|
|
|
class TransferListWidget;
|
2009-11-08 15:05:35 +03:00
|
|
|
class TransferListFiltersWidget;
|
2009-11-08 17:20:58 +03:00
|
|
|
class PropertiesWidget;
|
2009-11-18 16:18:55 +03:00
|
|
|
class StatusBar;
|
2010-03-03 17:42:57 +03:00
|
|
|
class about;
|
2010-10-23 00:13:22 +04:00
|
|
|
class TorrentCreatorDlg;
|
2010-03-10 23:21:56 +03:00
|
|
|
class downloadFromURL;
|
2010-08-20 16:27:20 +04:00
|
|
|
class LineEdit;
|
2010-12-20 21:07:36 +03:00
|
|
|
class ExecutionLog;
|
2011-02-06 17:27:34 +03:00
|
|
|
class PowerManagement;
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2011-02-27 18:41:05 +03:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QCloseEvent;
|
|
|
|
class QFileSystemWatcher;
|
|
|
|
class QShortcut;
|
|
|
|
class QSplitter;
|
|
|
|
class QTabWidget;
|
|
|
|
class QTimer;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2015-04-19 18:17:47 +03:00
|
|
|
namespace BitTorrent
|
|
|
|
{
|
|
|
|
class TorrentHandle;
|
|
|
|
}
|
|
|
|
|
2014-12-20 20:53:58 +03:00
|
|
|
class MainWindow: public QMainWindow, private Ui::MainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2010-03-03 17:48:49 +03:00
|
|
|
public:
|
2014-12-20 20:53:58 +03:00
|
|
|
// Construct / Destruct
|
2015-01-22 15:56:16 +03:00
|
|
|
explicit MainWindow(QWidget *parent = 0);
|
2015-01-26 17:00:23 +03:00
|
|
|
~MainWindow();
|
2014-12-20 20:53:58 +03:00
|
|
|
// Methods
|
|
|
|
QWidget* getCurrentTabWidget() const;
|
|
|
|
TransferListWidget* getTransferList() const { return transferList; }
|
|
|
|
QMenu* getTrayIconMenu();
|
|
|
|
PropertiesWidget *getProperties() const { return properties; }
|
2010-03-03 17:48:49 +03:00
|
|
|
|
|
|
|
public slots:
|
2015-04-19 18:17:47 +03:00
|
|
|
void trackerAuthenticationRequired(BitTorrent::TorrentHandle *const torrent);
|
2014-12-20 20:53:58 +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();
|
2015-01-22 15:56:16 +03:00
|
|
|
void activate();
|
2015-04-16 00:47:59 +03:00
|
|
|
void cleanup();
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2010-01-06 01:31:06 +03:00
|
|
|
protected slots:
|
2014-12-20 20:53:58 +03:00
|
|
|
// GUI related slots
|
|
|
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
|
|
|
|
void on_actionAbout_triggered();
|
|
|
|
void on_actionStatistics_triggered();
|
|
|
|
void on_actionCreate_torrent_triggered();
|
|
|
|
void balloonClicked();
|
|
|
|
void writeSettings();
|
|
|
|
void readSettings();
|
|
|
|
void on_actionExit_triggered();
|
|
|
|
void createTrayIcon();
|
2015-04-19 18:17:47 +03:00
|
|
|
void fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const;
|
2014-12-20 20:53:58 +03:00
|
|
|
void handleDownloadFromUrlFailure(QString, QString) const;
|
|
|
|
void createSystrayDelayed();
|
|
|
|
void tab_changed(int);
|
|
|
|
void on_actionLock_qBittorrent_triggered();
|
|
|
|
void defineUILockPassword();
|
|
|
|
void clearUILockPassword();
|
|
|
|
bool unlockUI();
|
|
|
|
void notifyOfUpdate(QString);
|
|
|
|
void showConnectionSettings();
|
|
|
|
void minimizeWindow();
|
|
|
|
void updateTrayIconMenu();
|
|
|
|
// 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);
|
2015-10-16 09:36:22 +03:00
|
|
|
void addUnauthenticatedTracker(const QPair<BitTorrent::TorrentHandle*, QString> &tracker);
|
2015-04-19 18:17:47 +03:00
|
|
|
void addTorrentFailed(const QString &error) const;
|
|
|
|
void finishedTorrent(BitTorrent::TorrentHandle *const torrent) const;
|
|
|
|
void askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent);
|
2014-12-20 20:53:58 +03:00
|
|
|
// Options slots
|
|
|
|
void on_actionOptions_triggered();
|
|
|
|
void optionsSaved();
|
|
|
|
// HTTP slots
|
|
|
|
void on_actionDownload_from_URL_triggered();
|
2013-09-21 11:59:58 +04:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
2014-12-20 20:53:58 +03:00
|
|
|
void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser);
|
2010-10-24 01:46:05 +04:00
|
|
|
#endif
|
2015-03-10 21:21:29 +03:00
|
|
|
void updateRSSTabLabel(int count);
|
2009-03-28 01:25:34 +03:00
|
|
|
|
2010-01-06 01:31:06 +03:00
|
|
|
protected:
|
2015-01-26 17:00:23 +03:00
|
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
2014-12-20 20:53:58 +03:00
|
|
|
void closeEvent(QCloseEvent *);
|
|
|
|
void showEvent(QShowEvent *);
|
|
|
|
bool event(QEvent * event);
|
|
|
|
void displayRSSTab(bool enable);
|
|
|
|
void displaySearchTab(bool enable);
|
2006-09-30 20:02:39 +04:00
|
|
|
|
2011-03-12 23:59:44 +03:00
|
|
|
private:
|
2014-12-20 20:53:58 +03:00
|
|
|
QIcon getSystrayIcon() const;
|
2014-09-14 15:30:22 +04:00
|
|
|
#ifdef Q_OS_WIN
|
2014-12-20 20:53:58 +03:00
|
|
|
bool addPythonPathToEnv();
|
|
|
|
void installPython();
|
2014-11-30 01:34:25 +03:00
|
|
|
|
|
|
|
private slots:
|
2015-04-19 18:17:47 +03:00
|
|
|
void pythonDownloadSuccess(const QString &url, const QString &filePath);
|
|
|
|
void pythonDownloadFailure(const QString &url, const QString &error);
|
2014-09-14 15:30:22 +04:00
|
|
|
#endif
|
2014-10-18 18:18:58 +04:00
|
|
|
void addToolbarContextMenu();
|
2011-03-12 23:59:44 +03:00
|
|
|
|
2010-03-03 17:48:49 +03:00
|
|
|
private:
|
2014-12-20 20:53:58 +03:00
|
|
|
QFileSystemWatcher *executable_watcher;
|
|
|
|
// Bittorrent
|
2015-10-16 09:36:22 +03:00
|
|
|
QList<QPair<BitTorrent::TorrentHandle*, QString>> unauthenticated_trackers; // Still needed?
|
2014-12-20 20:53:58 +03:00
|
|
|
// GUI related
|
|
|
|
bool m_posInitialized;
|
2015-01-26 17:00:23 +03:00
|
|
|
QTabWidget *tabs;
|
2014-12-20 20:53:58 +03:00
|
|
|
StatusBar *status_bar;
|
|
|
|
QPointer<options_imp> options;
|
|
|
|
QPointer<about> aboutDlg;
|
|
|
|
QPointer<StatsDialog> statsDlg;
|
|
|
|
QPointer<TorrentCreatorDlg> createTorrentDlg;
|
|
|
|
QPointer<downloadFromURL> downloadFromURLDialog;
|
|
|
|
QPointer<QSystemTrayIcon> systrayIcon;
|
|
|
|
QPointer<QTimer> systrayCreator;
|
|
|
|
QPointer<QMenu> myTrayIconMenu;
|
|
|
|
TransferListWidget *transferList;
|
|
|
|
TransferListFiltersWidget *transferListFilters;
|
|
|
|
PropertiesWidget *properties;
|
|
|
|
bool displaySpeedInTitle;
|
|
|
|
bool force_exit;
|
|
|
|
bool ui_locked;
|
|
|
|
bool unlockDlgShowing;
|
|
|
|
LineEdit *search_filter;
|
|
|
|
QAction *searchFilterAct;
|
|
|
|
// Widgets
|
|
|
|
QAction *prioSeparator;
|
|
|
|
QAction *prioSeparatorMenu;
|
|
|
|
QSplitter *hSplitter;
|
|
|
|
QSplitter *vSplitter;
|
|
|
|
// Search
|
2015-08-26 20:05:57 +03:00
|
|
|
QPointer<SearchWidget> searchEngine;
|
2014-12-20 20:53:58 +03:00
|
|
|
// RSS
|
|
|
|
QPointer<RSSImp> rssWidget;
|
|
|
|
// Execution Log
|
|
|
|
QPointer<ExecutionLog> m_executionLog;
|
|
|
|
// Power Management
|
|
|
|
PowerManagement *m_pwr;
|
|
|
|
QTimer *preventTimer;
|
2013-09-21 11:59:58 +04:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
2014-12-20 20:53:58 +03:00
|
|
|
QTimer programUpdateTimer;
|
2015-12-13 17:41:58 +03:00
|
|
|
bool m_wasUpdateCheckEnabled;
|
2013-11-23 16:58:03 +04:00
|
|
|
#endif
|
2014-12-20 20:53:58 +03:00
|
|
|
bool has_python;
|
2014-10-18 18:18:58 +04:00
|
|
|
QMenu* toolbarMenu;
|
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();
|
2010-10-23 20:21:56 +04:00
|
|
|
void on_action_Import_Torrent_triggered();
|
2010-10-31 15:03:24 +03:00
|
|
|
void on_actionDonate_money_triggered();
|
2010-12-20 21:07:36 +03:00
|
|
|
void on_actionExecution_Logs_triggered(bool checked);
|
2010-12-31 16:36:32 +03:00
|
|
|
void on_actionAutoExit_qBittorrent_toggled(bool );
|
|
|
|
void on_actionAutoSuspend_system_toggled(bool );
|
2014-07-06 13:13:36 +04:00
|
|
|
void on_actionAutoHibernate_system_toggled(bool );
|
2010-12-31 16:36:32 +03:00
|
|
|
void on_actionAutoShutdown_system_toggled(bool );
|
2011-02-06 17:27:34 +03:00
|
|
|
// Check for active torrents and set preventing from suspend state
|
|
|
|
void checkForActiveTorrents();
|
2013-09-21 11:59:58 +04:00
|
|
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
2013-11-23 16:58:03 +04:00
|
|
|
void checkProgramUpdate();
|
|
|
|
#endif
|
2014-10-18 18:18:58 +04:00
|
|
|
void toolbarMenuRequested(QPoint);
|
|
|
|
void toolbarIconsOnly();
|
|
|
|
void toolbarTextOnly();
|
|
|
|
void toolbarTextBeside();
|
|
|
|
void toolbarTextUnder();
|
|
|
|
void toolbarFollowSystem();
|
2006-09-30 20:02:39 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|