2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2009-2014 Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2009-05-31 19:33:48 +00:00
|
|
|
* $Id$
|
2009-04-09 18:55:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MAIN_WINDOW_H
|
|
|
|
#define MAIN_WINDOW_H
|
|
|
|
|
|
|
|
#include <ctime>
|
2009-04-15 01:59:54 +00:00
|
|
|
#include <QLineEdit>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QIcon>
|
|
|
|
#include <QMainWindow>
|
2009-04-15 01:59:54 +00:00
|
|
|
#include <QMap>
|
2010-06-17 05:56:48 +00:00
|
|
|
#include <QPushButton>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QSet>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidgetList>
|
2013-10-20 19:57:48 +00:00
|
|
|
#include <QNetworkReply>
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2013-08-24 19:26:21 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
struct tr_variant;
|
|
|
|
}
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-04-15 01:59:54 +00:00
|
|
|
#include "filters.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
#include "torrent-filter.h"
|
|
|
|
#include "ui_mainwin.h"
|
|
|
|
|
2013-02-09 23:11:17 +00:00
|
|
|
class AddData;
|
2009-04-09 18:55:47 +00:00
|
|
|
class ActionDelegator;
|
|
|
|
class Prefs;
|
2009-04-18 23:18:28 +00:00
|
|
|
class Details;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
|
|
|
class TorrentDelegate;
|
|
|
|
class TorrentDelegateMin;
|
|
|
|
class TorrentModel;
|
2009-04-14 22:05:11 +00:00
|
|
|
class QAction;
|
2009-04-15 01:59:54 +00:00
|
|
|
class QLabel;
|
2009-04-14 22:05:11 +00:00
|
|
|
class QMenu;
|
2009-04-09 18:55:47 +00:00
|
|
|
class QModelIndex;
|
|
|
|
class QSortFilterProxyModel;
|
2010-07-30 22:31:31 +00:00
|
|
|
class Filterbar;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
class TrMainWindow: public QMainWindow
|
|
|
|
{
|
2013-01-27 18:09:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void hideEvent (QHideEvent * event);
|
|
|
|
virtual void showEvent (QShowEvent * event);
|
|
|
|
|
|
|
|
private:
|
|
|
|
time_t myLastFullUpdateTime;
|
|
|
|
QDialog * mySessionDialog;
|
|
|
|
QDialog * myPrefsDialog;
|
|
|
|
QDialog * myAboutDialog;
|
|
|
|
QDialog * myStatsDialog;
|
|
|
|
Details * myDetailsDialog;
|
|
|
|
QSystemTrayIcon myTrayIcon;
|
|
|
|
TorrentFilter myFilterModel;
|
|
|
|
TorrentDelegate * myTorrentDelegate;
|
|
|
|
TorrentDelegateMin * myTorrentDelegateMin;
|
|
|
|
Session& mySession;
|
|
|
|
Prefs& myPrefs;
|
|
|
|
TorrentModel& myModel;
|
|
|
|
Ui_MainWindow ui;
|
|
|
|
QIcon mySpeedModeOffIcon;
|
|
|
|
QIcon mySpeedModeOnIcon;
|
|
|
|
time_t myLastSendTime;
|
|
|
|
time_t myLastReadTime;
|
|
|
|
QTimer myNetworkTimer;
|
2013-10-20 19:57:48 +00:00
|
|
|
bool myNetworkError;
|
2013-01-27 18:09:49 +00:00
|
|
|
QTimer myRefreshTrayIconTimer;
|
|
|
|
QTimer myRefreshActionSensitivityTimer;
|
|
|
|
QAction * myDlimitOffAction;
|
|
|
|
QAction * myDlimitOnAction;
|
|
|
|
QAction * myUlimitOffAction;
|
|
|
|
QAction * myUlimitOnAction;
|
|
|
|
QAction * myRatioOffAction;
|
|
|
|
QAction * myRatioOnAction;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QIcon getStockIcon (const QString&, int fallback=-1);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QSet<int> getSelectedTorrents () const;
|
|
|
|
void updateNetworkIcon ();
|
|
|
|
QWidgetList myHidden;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onPrefsDestroyed ();
|
|
|
|
void openPreferences ();
|
|
|
|
void onDetailsDestroyed ();
|
|
|
|
void showTotalRatio ();
|
|
|
|
void showTotalTransfer ();
|
|
|
|
void showSessionRatio ();
|
|
|
|
void showSessionTransfer ();
|
|
|
|
void refreshTitle ();
|
|
|
|
void refreshStatusBar ();
|
|
|
|
void refreshTrayIcon ();
|
|
|
|
void refreshTrayIconSoon ();
|
|
|
|
void openTorrent ();
|
|
|
|
void openURL ();
|
|
|
|
void newTorrent ();
|
|
|
|
void trayActivated (QSystemTrayIcon::ActivationReason);
|
|
|
|
void refreshPref (int key);
|
|
|
|
void addTorrents (const QStringList& filenames);
|
|
|
|
void removeTorrents (const bool deleteFiles);
|
|
|
|
void openDonate ();
|
|
|
|
void openHelp ();
|
|
|
|
void openFolder ();
|
|
|
|
void copyMagnetLinkToClipboard ();
|
|
|
|
void setLocation ();
|
|
|
|
void openProperties ();
|
|
|
|
void toggleSpeedMode ();
|
|
|
|
void dataReadProgress ();
|
|
|
|
void dataSendProgress ();
|
2013-10-20 19:57:48 +00:00
|
|
|
void onError (QNetworkReply::NetworkError);
|
|
|
|
void errorMessage (const QString);
|
2013-01-27 18:09:49 +00:00
|
|
|
void toggleWindows (bool doShow);
|
|
|
|
void onSetPrefs ();
|
|
|
|
void onSetPrefs (bool);
|
|
|
|
void onSessionSourceChanged ();
|
|
|
|
void onModelReset ();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void setSortPref (int);
|
|
|
|
void setSortAscendingPref (bool);
|
|
|
|
void onSortByActivityToggled (bool);
|
|
|
|
void onSortByAgeToggled (bool);
|
|
|
|
void onSortByETAToggled (bool);
|
|
|
|
void onSortByNameToggled (bool);
|
|
|
|
void onSortByProgressToggled (bool);
|
|
|
|
void onSortByQueueToggled (bool);
|
|
|
|
void onSortByRatioToggled (bool);
|
|
|
|
void onSortBySizeToggled (bool);
|
|
|
|
void onSortByStateToggled (bool);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QWidget * myFilterBar;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMenu * createOptionsMenu (void);
|
|
|
|
QWidget * createStatusBar (void);
|
|
|
|
QWidget * myStatusBar;
|
|
|
|
QPushButton * myAltSpeedButton;
|
|
|
|
QAction * myAltSpeedAction;
|
|
|
|
QPushButton * myOptionsButton;
|
|
|
|
QPushButton * myStatsModeButton;
|
|
|
|
QLabel * myStatsLabel;
|
|
|
|
QLabel * myDownloadSpeedLabel;
|
|
|
|
QLabel * myUploadSpeedLabel;
|
|
|
|
QLabel * myNetworkLabel;
|
2013-10-20 19:57:48 +00:00
|
|
|
QString myErrorMessage;
|
2013-01-27 18:09:49 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void startAll ();
|
|
|
|
void startSelected ();
|
|
|
|
void startSelectedNow ();
|
|
|
|
void pauseAll ();
|
|
|
|
void pauseSelected ();
|
|
|
|
void removeSelected ();
|
|
|
|
void deleteSelected ();
|
|
|
|
void verifySelected ();
|
|
|
|
void queueMoveTop ();
|
|
|
|
void queueMoveUp ();
|
|
|
|
void queueMoveDown ();
|
|
|
|
void queueMoveBottom ();
|
|
|
|
void reannounceSelected ();
|
|
|
|
void onNetworkTimer ();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void clearSelection ();
|
2013-09-14 22:50:25 +00:00
|
|
|
void addTorrent (const AddData& addMe, bool showOptions);
|
2013-01-27 18:09:49 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setToolbarVisible (bool);
|
|
|
|
void setFilterbarVisible (bool);
|
|
|
|
void setStatusbarVisible (bool);
|
|
|
|
void setCompactView (bool);
|
|
|
|
void refreshActionSensitivity ();
|
|
|
|
void refreshActionSensitivitySoon ();
|
|
|
|
void wrongAuthentication ();
|
|
|
|
|
|
|
|
public:
|
|
|
|
TrMainWindow (Session&, Prefs&, TorrentModel&, bool minized);
|
|
|
|
virtual ~TrMainWindow ();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void contextMenuEvent (QContextMenuEvent *);
|
|
|
|
virtual void dragEnterEvent (QDragEnterEvent *);
|
|
|
|
virtual void dropEvent (QDropEvent *);
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|