2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2015-06-10 21:27:11 +00:00
|
|
|
* This file Copyright (C) 2009-2015 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
|
|
|
*/
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#ifndef QTR_MAIN_WINDOW_H
|
|
|
|
#define QTR_MAIN_WINDOW_H
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
#include <ctime>
|
2015-06-12 22:12:12 +00:00
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QMainWindow>
|
2015-06-12 22:12:12 +00:00
|
|
|
#include <QNetworkReply>
|
2015-01-25 15:47:03 +00:00
|
|
|
#include <QPointer>
|
2009-04-09 18:55:47 +00:00
|
|
|
#include <QSet>
|
|
|
|
#include <QSystemTrayIcon>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QWidgetList>
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#include "Filters.h"
|
|
|
|
#include "TorrentFilter.h"
|
|
|
|
#include "ui_MainWindow.h"
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
class QAction;
|
|
|
|
class QIcon;
|
|
|
|
class QMenu;
|
|
|
|
|
2015-07-30 06:18:02 +00:00
|
|
|
class AboutDialog;
|
2013-02-09 23:11:17 +00:00
|
|
|
class AddData;
|
2015-06-10 21:27:11 +00:00
|
|
|
class DetailsDialog;
|
2015-07-30 06:18:02 +00:00
|
|
|
class Prefs;
|
|
|
|
class PrefsDialog;
|
2009-04-09 18:55:47 +00:00
|
|
|
class Session;
|
2015-07-30 06:18:02 +00:00
|
|
|
class SessionDialog;
|
|
|
|
class StatsDialog;
|
2009-04-09 18:55:47 +00:00
|
|
|
class TorrentDelegate;
|
|
|
|
class TorrentDelegateMin;
|
|
|
|
class TorrentModel;
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
struct tr_variant;
|
|
|
|
}
|
|
|
|
|
|
|
|
class MainWindow: public QMainWindow
|
2009-04-09 18:55:47 +00:00
|
|
|
{
|
2013-01-27 18:09:49 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
public:
|
|
|
|
MainWindow (Session&, Prefs&, TorrentModel&, bool minized);
|
|
|
|
virtual ~MainWindow ();
|
2013-01-27 18:09:49 +00:00
|
|
|
|
2015-06-12 22:12:12 +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 ();
|
2013-01-27 18:09:49 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
void setToolbarVisible (bool);
|
|
|
|
void setFilterbarVisible (bool);
|
|
|
|
void setStatusbarVisible (bool);
|
|
|
|
void setCompactView (bool);
|
|
|
|
void refreshActionSensitivity ();
|
|
|
|
void refreshActionSensitivitySoon ();
|
|
|
|
void wrongAuthentication ();
|
|
|
|
|
2015-07-30 06:18:02 +00:00
|
|
|
void openSession ();
|
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
protected:
|
|
|
|
// QWidget
|
|
|
|
virtual void contextMenuEvent (QContextMenuEvent *);
|
|
|
|
virtual void dragEnterEvent (QDragEnterEvent *);
|
|
|
|
virtual void dropEvent (QDropEvent *);
|
2013-01-27 18:09:49 +00:00
|
|
|
|
|
|
|
private:
|
2015-06-12 22:12:12 +00:00
|
|
|
QIcon getStockIcon (const QString&, int fallback = -1);
|
|
|
|
|
2013-01-27 18:09:49 +00:00
|
|
|
QSet<int> getSelectedTorrents () const;
|
|
|
|
void updateNetworkIcon ();
|
2015-06-12 22:12:12 +00:00
|
|
|
|
|
|
|
QMenu * createOptionsMenu ();
|
|
|
|
QMenu * createStatsModeMenu ();
|
|
|
|
void initStatusBar ();
|
|
|
|
|
|
|
|
void clearSelection ();
|
|
|
|
void addTorrent (const AddData& addMe, bool showOptions);
|
|
|
|
|
|
|
|
// QWidget
|
|
|
|
virtual void hideEvent (QHideEvent * event);
|
|
|
|
virtual void showEvent (QShowEvent * event);
|
2013-01-27 18:09:49 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void openPreferences ();
|
|
|
|
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);
|
2015-07-30 06:18:02 +00:00
|
|
|
void openStats ();
|
2013-01-27 18:09:49 +00:00
|
|
|
void openDonate ();
|
2015-07-30 06:18:02 +00:00
|
|
|
void openAbout ();
|
2013-01-27 18:09:49 +00:00
|
|
|
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);
|
2014-12-12 23:52:17 +00:00
|
|
|
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 ();
|
|
|
|
|
|
|
|
void setSortAscendingPref (bool);
|
2015-08-06 20:28:44 +00:00
|
|
|
|
|
|
|
void onStatsModeChanged (QAction * action);
|
|
|
|
void onSortModeChanged (QAction * action);
|
2013-01-27 18:09:49 +00:00
|
|
|
|
|
|
|
private:
|
2015-06-12 22:12:12 +00:00
|
|
|
Session& mySession;
|
|
|
|
Prefs& myPrefs;
|
|
|
|
TorrentModel& myModel;
|
2013-01-27 18:09:49 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
Ui_MainWindow ui;
|
2014-12-18 01:30:50 +00:00
|
|
|
|
2015-06-12 22:12:12 +00:00
|
|
|
time_t myLastFullUpdateTime;
|
2015-07-30 06:18:02 +00:00
|
|
|
QPointer<SessionDialog> mySessionDialog;
|
|
|
|
QPointer<PrefsDialog> myPrefsDialog;
|
|
|
|
QPointer<AboutDialog> myAboutDialog;
|
|
|
|
QPointer<StatsDialog> myStatsDialog;
|
|
|
|
QPointer<DetailsDialog> myDetailsDialog;
|
2015-06-12 22:12:12 +00:00
|
|
|
QSystemTrayIcon myTrayIcon;
|
|
|
|
TorrentFilter myFilterModel;
|
|
|
|
TorrentDelegate * myTorrentDelegate;
|
|
|
|
TorrentDelegateMin * myTorrentDelegateMin;
|
|
|
|
time_t myLastSendTime;
|
|
|
|
time_t myLastReadTime;
|
|
|
|
QTimer myNetworkTimer;
|
|
|
|
bool myNetworkError;
|
|
|
|
QTimer myRefreshTrayIconTimer;
|
|
|
|
QTimer myRefreshActionSensitivityTimer;
|
|
|
|
QAction * myDlimitOffAction;
|
|
|
|
QAction * myDlimitOnAction;
|
|
|
|
QAction * myUlimitOffAction;
|
|
|
|
QAction * myUlimitOnAction;
|
|
|
|
QAction * myRatioOffAction;
|
|
|
|
QAction * myRatioOnAction;
|
|
|
|
QWidgetList myHidden;
|
|
|
|
QWidget * myFilterBar;
|
2013-01-27 18:09:49 +00:00
|
|
|
QAction * myAltSpeedAction;
|
2013-10-20 19:57:48 +00:00
|
|
|
QString myErrorMessage;
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
2015-06-10 21:27:11 +00:00
|
|
|
#endif // QTR_MAIN_WINDOW_H
|