1 | /* |
---|
2 | * This file Copyright (C) 2009-2010 Mnemosyne LLC |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2(b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: mainwin.h 10860 2010-06-25 21:04:34Z charles $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef MAIN_WINDOW_H |
---|
14 | #define MAIN_WINDOW_H |
---|
15 | |
---|
16 | #include <ctime> |
---|
17 | #include <QCheckBox> |
---|
18 | #include <QFileDialog> |
---|
19 | #include <QLineEdit> |
---|
20 | #include <QIcon> |
---|
21 | #include <QMainWindow> |
---|
22 | #include <QMap> |
---|
23 | #include <QSet> |
---|
24 | #include <QSystemTrayIcon> |
---|
25 | #include <QTimer> |
---|
26 | #include <QWidgetList> |
---|
27 | |
---|
28 | extern "C" { |
---|
29 | struct tr_benc; |
---|
30 | }; |
---|
31 | |
---|
32 | #include "filters.h" |
---|
33 | #include "torrent-filter.h" |
---|
34 | #include "ui_mainwin.h" |
---|
35 | |
---|
36 | class ActionDelegator; |
---|
37 | class Prefs; |
---|
38 | class Details; |
---|
39 | class Session; |
---|
40 | class TorrentDelegate; |
---|
41 | class TorrentDelegateMin; |
---|
42 | class TorrentModel; |
---|
43 | class QAction; |
---|
44 | class QLabel; |
---|
45 | class QMenu; |
---|
46 | class QModelIndex; |
---|
47 | class QSortFilterProxyModel; |
---|
48 | |
---|
49 | class TrMainWindow: public QMainWindow |
---|
50 | { |
---|
51 | Q_OBJECT |
---|
52 | |
---|
53 | private: |
---|
54 | virtual void closeEvent( QCloseEvent * event ); |
---|
55 | |
---|
56 | private: |
---|
57 | time_t myLastFullUpdateTime; |
---|
58 | QDialog * mySessionDialog; |
---|
59 | QDialog * myPrefsDialog; |
---|
60 | QDialog * myAboutDialog; |
---|
61 | QDialog * myStatsDialog; |
---|
62 | Details * myDetailsDialog; |
---|
63 | QFileDialog * myFileDialog; |
---|
64 | QCheckBox * myFileDialogOptionsCheck; |
---|
65 | QSystemTrayIcon myTrayIcon; |
---|
66 | TorrentFilter myFilterModel; |
---|
67 | TorrentDelegate * myTorrentDelegate; |
---|
68 | TorrentDelegateMin * myTorrentDelegateMin; |
---|
69 | Session& mySession; |
---|
70 | Prefs& myPrefs; |
---|
71 | TorrentModel& myModel; |
---|
72 | Ui_MainWindow ui; |
---|
73 | QIcon mySpeedModeOffIcon; |
---|
74 | QIcon mySpeedModeOnIcon; |
---|
75 | time_t myLastSendTime; |
---|
76 | time_t myLastReadTime; |
---|
77 | QTimer myNetworkTimer; |
---|
78 | QAction * myDlimitOffAction; |
---|
79 | QAction * myDlimitOnAction; |
---|
80 | QAction * myUlimitOffAction; |
---|
81 | QAction * myUlimitOnAction; |
---|
82 | QAction * myRatioOffAction; |
---|
83 | QAction * myRatioOnAction; |
---|
84 | |
---|
85 | private: |
---|
86 | QIcon getStockIcon( const QString&, int fallback=-1 ); |
---|
87 | |
---|
88 | private: |
---|
89 | void setShowMode( int ); |
---|
90 | QSet<int> getSelectedTorrents( ) const; |
---|
91 | void updateNetworkIcon( ); |
---|
92 | QWidgetList myHidden; |
---|
93 | |
---|
94 | public slots: |
---|
95 | void openURL( QString ); |
---|
96 | |
---|
97 | private slots: |
---|
98 | void onPrefsDestroyed( ); |
---|
99 | void openPreferences( ); |
---|
100 | void onDetailsDestroyed( ); |
---|
101 | void onShowModeClicked( ); |
---|
102 | void showAll( ); |
---|
103 | void showActive( ); |
---|
104 | void showDownloading( ); |
---|
105 | void showSeeding( ); |
---|
106 | void showPaused( ); |
---|
107 | void filterByName( ); |
---|
108 | void filterByFiles( ); |
---|
109 | void filterByTracker( ); |
---|
110 | void showTotalRatio( ); |
---|
111 | void showTotalTransfer( ); |
---|
112 | void showSessionRatio( ); |
---|
113 | void showSessionTransfer( ); |
---|
114 | void refreshVisibleCount( ); |
---|
115 | void refreshTitle( ); |
---|
116 | void refreshStatusBar( ); |
---|
117 | void openTorrent( ); |
---|
118 | void openURL( ); |
---|
119 | void newTorrent( ); |
---|
120 | void trayActivated( QSystemTrayIcon::ActivationReason ); |
---|
121 | void refreshPref( int key ); |
---|
122 | void addTorrents( const QStringList& filenames ); |
---|
123 | void removeTorrents( const bool deleteFiles ); |
---|
124 | void openHelp( ); |
---|
125 | void openFolder( ); |
---|
126 | void copyMagnetLinkToClipboard( ); |
---|
127 | void setLocation( ); |
---|
128 | void openProperties( ); |
---|
129 | void toggleSpeedMode( ); |
---|
130 | void dataReadProgress( ); |
---|
131 | void dataSendProgress( ); |
---|
132 | void toggleWindows( bool doShow ); |
---|
133 | void onSetPrefs( ); |
---|
134 | void onSetPrefs( bool ); |
---|
135 | void onSessionSourceChanged( ); |
---|
136 | void onModelReset( ); |
---|
137 | |
---|
138 | private slots: |
---|
139 | void setSortPref ( int ); |
---|
140 | void setSortAscendingPref ( bool ); |
---|
141 | void onSortByActivityToggled ( bool ); |
---|
142 | void onSortByAgeToggled ( bool ); |
---|
143 | void onSortByETAToggled ( bool ); |
---|
144 | void onSortByNameToggled ( bool ); |
---|
145 | void onSortByProgressToggled ( bool ); |
---|
146 | void onSortByRatioToggled ( bool ); |
---|
147 | void onSortBySizeToggled ( bool ); |
---|
148 | void onSortByStateToggled ( bool ); |
---|
149 | void onSortByTrackerToggled ( bool ); |
---|
150 | |
---|
151 | private: |
---|
152 | QWidget * createFilterBar( void ); |
---|
153 | QWidget * myFilterBar; |
---|
154 | QPushButton * myFilterButtons[FilterMode::NUM_MODES]; |
---|
155 | QPushButton * myFilterTextButton; |
---|
156 | QLineEdit * myFilterTextLineEdit; |
---|
157 | |
---|
158 | private: |
---|
159 | QMenu * createOptionsMenu( void ); |
---|
160 | QWidget * createStatusBar( void ); |
---|
161 | QWidget * myStatusBar; |
---|
162 | QPushButton * myAltSpeedButton; |
---|
163 | QPushButton * myOptionsButton; |
---|
164 | QLabel * myVisibleCountLabel; |
---|
165 | QPushButton * myStatsModeButton; |
---|
166 | QLabel * myStatsLabel; |
---|
167 | QLabel * myDownloadSpeedLabel; |
---|
168 | QLabel * myUploadSpeedLabel; |
---|
169 | QLabel * myNetworkLabel; |
---|
170 | |
---|
171 | public slots: |
---|
172 | void startAll( ); |
---|
173 | void startSelected( ); |
---|
174 | void pauseAll( ); |
---|
175 | void pauseSelected( ); |
---|
176 | void removeSelected( ); |
---|
177 | void deleteSelected( ); |
---|
178 | void verifySelected( ); |
---|
179 | void reannounceSelected( ); |
---|
180 | void addTorrent( const QString& filename ); |
---|
181 | void onNetworkTimer( ); |
---|
182 | |
---|
183 | private: |
---|
184 | void clearSelection( ); |
---|
185 | |
---|
186 | public slots: |
---|
187 | void setToolbarVisible( bool ); |
---|
188 | void setFilterbarVisible( bool ); |
---|
189 | void setStatusbarVisible( bool ); |
---|
190 | void setTrayIconVisible( bool ); |
---|
191 | void setCompactView( bool ); |
---|
192 | void refreshActionSensitivity( ); |
---|
193 | void wrongAuthentication( ); |
---|
194 | |
---|
195 | public: |
---|
196 | TrMainWindow( Session&, Prefs&, TorrentModel&, bool minized ); |
---|
197 | virtual ~TrMainWindow( ); |
---|
198 | }; |
---|
199 | |
---|
200 | #endif |
---|