2009-04-09 18:55:47 +00:00
|
|
|
/*
|
|
|
|
* This file Copyright (C) 2009 Charles Kerr <charles@transmissionbt.com>
|
|
|
|
*
|
|
|
|
* This file is licensed by the GPL version 2. Works owned by the
|
|
|
|
* Transmission project are granted a special exemption to clause 2(b)
|
|
|
|
* so that the bulk of its code can remain under the MIT license.
|
|
|
|
* This exemption does not extend to derived works not owned by
|
|
|
|
* the Transmission project.
|
|
|
|
*
|
|
|
|
* $Id:$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MAIN_WINDOW_H
|
|
|
|
#define MAIN_WINDOW_H
|
|
|
|
|
|
|
|
#include <ctime>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QFileDialog>
|
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>
|
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;
|
|
|
|
|
|
|
|
class TrMainWindow: public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
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
|
|
|
QFileDialog * myFileDialog;
|
|
|
|
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;
|
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:
|
2009-05-06 13:39:48 +00:00
|
|
|
void setShowMode( int );
|
2009-04-09 18:55:47 +00:00
|
|
|
QSet<int> getSelectedTorrents( ) const;
|
|
|
|
void updateNetworkIcon( );
|
|
|
|
QWidgetList myHidden;
|
|
|
|
|
|
|
|
private slots:
|
2009-04-18 23:18:28 +00:00
|
|
|
void onDetailsDestroyed( );
|
2009-05-06 13:39:48 +00:00
|
|
|
void onShowModeClicked( );
|
|
|
|
void showAll( );
|
|
|
|
void showActive( );
|
|
|
|
void showDownloading( );
|
|
|
|
void showSeeding( );
|
|
|
|
void showPaused( );
|
2009-04-09 18:55:47 +00:00
|
|
|
void filterByName( );
|
|
|
|
void filterByFiles( );
|
|
|
|
void filterByTracker( );
|
|
|
|
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( );
|
|
|
|
void openTorrent( );
|
|
|
|
void newTorrent( );
|
|
|
|
void trayActivated( QSystemTrayIcon::ActivationReason );
|
|
|
|
void refreshPref( int key );
|
|
|
|
void addTorrents( const QStringList& filenames );
|
|
|
|
void openHelp( );
|
|
|
|
void openFolder( );
|
|
|
|
void openProperties( );
|
|
|
|
void toggleSpeedMode( );
|
|
|
|
void dataReadProgress( );
|
|
|
|
void dataSendProgress( );
|
|
|
|
void toggleWindows( );
|
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 );
|
|
|
|
void onSortByRatioToggled ( bool );
|
|
|
|
void onSortBySizeToggled ( bool );
|
|
|
|
void onSortByStateToggled ( bool );
|
|
|
|
void onSortByTrackerToggled ( bool );
|
|
|
|
|
|
|
|
private:
|
2009-04-15 01:59:54 +00:00
|
|
|
QWidget * createFilterBar( void );
|
|
|
|
QWidget * myFilterBar;
|
|
|
|
QPushButton * myFilterButtons[FilterMode::NUM_MODES];
|
|
|
|
QPushButton * myFilterTextButton;
|
|
|
|
QLineEdit * myFilterTextLineEdit;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMenu * createOptionsMenu( void );
|
|
|
|
QWidget * createStatusBar( void );
|
|
|
|
QWidget * myStatusBar;
|
2009-05-02 14:25:18 +00:00
|
|
|
QWidgetList myUpStatusWidgets;
|
|
|
|
QWidgetList myDownStatusWidgets;
|
2009-04-15 01:59:54 +00:00
|
|
|
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( );
|
|
|
|
void pauseAll( );
|
|
|
|
void pauseSelected( );
|
|
|
|
void removeSelected( );
|
|
|
|
void deleteSelected( );
|
|
|
|
void verifySelected( );
|
|
|
|
void reannounceSelected( );
|
|
|
|
void addTorrent( const QString& filename );
|
|
|
|
void onNetworkTimer( );
|
|
|
|
|
|
|
|
private:
|
|
|
|
void clearSelection( );
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void setToolbarVisible( bool );
|
|
|
|
void setFilterbarVisible( bool );
|
|
|
|
void setStatusbarVisible( bool );
|
|
|
|
void setTrayIconVisible( bool );
|
|
|
|
void setMinimalView( bool );
|
|
|
|
void refreshActionSensitivity( );
|
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( );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|