2009-04-09 18:55:47 +00:00
|
|
|
/*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This file Copyright (C) Mnemosyne LLC
|
2009-04-09 18:55:47 +00:00
|
|
|
*
|
2010-08-01 20:36:13 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
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>
|
|
|
|
#include <QCheckBox>
|
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>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
struct tr_benc;
|
|
|
|
};
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2009-09-26 04:39:58 +00:00
|
|
|
private:
|
|
|
|
virtual void closeEvent( QCloseEvent * event );
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
private:
|
|
|
|
time_t myLastFullUpdateTime;
|
2009-05-03 22:00:56 +00:00
|
|
|
QDialog * mySessionDialog;
|
2009-04-09 18:55:47 +00:00
|
|
|
QDialog * myPrefsDialog;
|
|
|
|
QDialog * myAboutDialog;
|
|
|
|
QDialog * myStatsDialog;
|
2009-04-18 23:18:28 +00:00
|
|
|
Details * myDetailsDialog;
|
2009-04-09 18:55:47 +00:00
|
|
|
QCheckBox * myFileDialogOptionsCheck;
|
|
|
|
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;
|
2011-07-13 17:22:01 +00:00
|
|
|
QTimer myRefreshTrayIconTimer;
|
2011-07-19 21:19:18 +00:00
|
|
|
QTimer myRefreshActionSensitivityTimer;
|
2009-04-14 22:05:11 +00:00
|
|
|
QAction * myDlimitOffAction;
|
|
|
|
QAction * myDlimitOnAction;
|
|
|
|
QAction * myUlimitOffAction;
|
|
|
|
QAction * myUlimitOnAction;
|
|
|
|
QAction * myRatioOffAction;
|
|
|
|
QAction * myRatioOnAction;
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QIcon getStockIcon( const QString&, int fallback=-1 );
|
|
|
|
|
|
|
|
private:
|
|
|
|
QSet<int> getSelectedTorrents( ) const;
|
|
|
|
void updateNetworkIcon( );
|
|
|
|
QWidgetList myHidden;
|
|
|
|
|
2010-04-27 03:10:32 +00:00
|
|
|
public slots:
|
|
|
|
void openURL( QString );
|
|
|
|
|
2009-04-09 18:55:47 +00:00
|
|
|
private slots:
|
2010-05-06 04:49:10 +00:00
|
|
|
void onPrefsDestroyed( );
|
|
|
|
void openPreferences( );
|
2009-04-18 23:18:28 +00:00
|
|
|
void onDetailsDestroyed( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void showTotalRatio( );
|
|
|
|
void showTotalTransfer( );
|
|
|
|
void showSessionRatio( );
|
|
|
|
void showSessionTransfer( );
|
|
|
|
void refreshVisibleCount( );
|
2009-05-03 17:37:39 +00:00
|
|
|
void refreshTitle( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void refreshStatusBar( );
|
2010-08-05 15:01:40 +00:00
|
|
|
void refreshTrayIcon( );
|
2011-07-13 17:22:01 +00:00
|
|
|
void refreshTrayIconSoon( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void openTorrent( );
|
2009-12-03 17:23:53 +00:00
|
|
|
void openURL( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void newTorrent( );
|
|
|
|
void trayActivated( QSystemTrayIcon::ActivationReason );
|
|
|
|
void refreshPref( int key );
|
|
|
|
void addTorrents( const QStringList& filenames );
|
2010-04-23 03:58:42 +00:00
|
|
|
void removeTorrents( const bool deleteFiles );
|
2010-08-02 03:07:42 +00:00
|
|
|
void openDonate( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void openHelp( );
|
|
|
|
void openFolder( );
|
2009-12-03 15:23:43 +00:00
|
|
|
void copyMagnetLinkToClipboard( );
|
2009-05-13 15:54:04 +00:00
|
|
|
void setLocation( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void openProperties( );
|
|
|
|
void toggleSpeedMode( );
|
|
|
|
void dataReadProgress( );
|
|
|
|
void dataSendProgress( );
|
2009-08-11 18:57:49 +00:00
|
|
|
void toggleWindows( bool doShow );
|
2009-04-14 22:05:11 +00:00
|
|
|
void onSetPrefs( );
|
|
|
|
void onSetPrefs( bool );
|
2009-05-03 17:37:39 +00:00
|
|
|
void onSessionSourceChanged( );
|
2009-05-03 18:35:33 +00:00
|
|
|
void onModelReset( );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
2009-04-14 22:05:11 +00:00
|
|
|
private slots:
|
|
|
|
void setSortPref ( int );
|
|
|
|
void setSortAscendingPref ( bool );
|
|
|
|
void onSortByActivityToggled ( bool );
|
|
|
|
void onSortByAgeToggled ( bool );
|
|
|
|
void onSortByETAToggled ( bool );
|
|
|
|
void onSortByNameToggled ( bool );
|
|
|
|
void onSortByProgressToggled ( bool );
|
2011-08-02 03:59:54 +00:00
|
|
|
void onSortByQueueToggled ( bool );
|
2009-04-14 22:05:11 +00:00
|
|
|
void onSortByRatioToggled ( bool );
|
|
|
|
void onSortBySizeToggled ( bool );
|
|
|
|
void onSortByStateToggled ( bool );
|
|
|
|
|
|
|
|
private:
|
2009-04-15 01:59:54 +00:00
|
|
|
QWidget * myFilterBar;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMenu * createOptionsMenu( void );
|
|
|
|
QWidget * createStatusBar( void );
|
|
|
|
QWidget * myStatusBar;
|
|
|
|
QPushButton * myAltSpeedButton;
|
|
|
|
QPushButton * myOptionsButton;
|
|
|
|
QLabel * myVisibleCountLabel;
|
|
|
|
QPushButton * myStatsModeButton;
|
|
|
|
QLabel * myStatsLabel;
|
|
|
|
QLabel * myDownloadSpeedLabel;
|
|
|
|
QLabel * myUploadSpeedLabel;
|
|
|
|
QLabel * myNetworkLabel;
|
2009-04-14 22:05:11 +00:00
|
|
|
|
|
|
|
public slots:
|
2009-04-09 18:55:47 +00:00
|
|
|
void startAll( );
|
|
|
|
void startSelected( );
|
2011-08-01 22:24:24 +00:00
|
|
|
void startSelectedNow( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void pauseAll( );
|
|
|
|
void pauseSelected( );
|
|
|
|
void removeSelected( );
|
|
|
|
void deleteSelected( );
|
|
|
|
void verifySelected( );
|
2011-08-01 22:24:24 +00:00
|
|
|
void queueMoveTop( );
|
|
|
|
void queueMoveUp( );
|
|
|
|
void queueMoveDown( );
|
|
|
|
void queueMoveBottom( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void reannounceSelected( );
|
|
|
|
void addTorrent( const QString& filename );
|
|
|
|
void onNetworkTimer( );
|
|
|
|
|
|
|
|
private:
|
|
|
|
void clearSelection( );
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setToolbarVisible( bool );
|
|
|
|
void setFilterbarVisible( bool );
|
|
|
|
void setStatusbarVisible( bool );
|
2010-03-15 14:42:56 +00:00
|
|
|
void setCompactView( bool );
|
2009-04-09 18:55:47 +00:00
|
|
|
void refreshActionSensitivity( );
|
2011-07-19 21:19:18 +00:00
|
|
|
void refreshActionSensitivitySoon( );
|
2009-05-03 22:00:56 +00:00
|
|
|
void wrongAuthentication( );
|
2009-04-09 18:55:47 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
TrMainWindow( Session&, Prefs&, TorrentModel&, bool minized );
|
|
|
|
virtual ~TrMainWindow( );
|
2010-07-31 23:11:05 +00:00
|
|
|
|
|
|
|
protected:
|
2011-08-01 22:24:24 +00:00
|
|
|
virtual void contextMenuEvent( QContextMenuEvent * );
|
2010-07-31 23:11:05 +00:00
|
|
|
virtual void dragEnterEvent( QDragEnterEvent * );
|
|
|
|
virtual void dropEvent( QDropEvent * );
|
2009-04-09 18:55:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|