1 | /* |
---|
2 | * This file Copyright (C) Mnemosyne LLC |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or modify |
---|
5 | * it under the terms of the GNU General Public License version 2 |
---|
6 | * as published by the Free Software Foundation. |
---|
7 | * |
---|
8 | * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
9 | * |
---|
10 | * $Id: mainwin.h 13883 2013-01-27 17:19:51Z jordan $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef MAIN_WINDOW_H |
---|
14 | #define MAIN_WINDOW_H |
---|
15 | |
---|
16 | #include <ctime> |
---|
17 | #include <QCheckBox> |
---|
18 | #include <QLineEdit> |
---|
19 | #include <QIcon> |
---|
20 | #include <QMainWindow> |
---|
21 | #include <QMap> |
---|
22 | #include <QPushButton> |
---|
23 | #include <QSet> |
---|
24 | #include <QSystemTrayIcon> |
---|
25 | #include <QTimer> |
---|
26 | #include <QWidgetList> |
---|
27 | |
---|
28 | extern "C" { |
---|
29 | struct tr_variant; |
---|
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 | class Filterbar; |
---|
49 | |
---|
50 | class TrMainWindow: public QMainWindow |
---|
51 | { |
---|
52 | Q_OBJECT |
---|
53 | |
---|
54 | private: |
---|
55 | virtual void hideEvent( QHideEvent * event ); |
---|
56 | virtual void showEvent( QShowEvent * event ); |
---|
57 | |
---|
58 | private: |
---|
59 | time_t myLastFullUpdateTime; |
---|
60 | QDialog * mySessionDialog; |
---|
61 | QDialog * myPrefsDialog; |
---|
62 | QDialog * myAboutDialog; |
---|
63 | QDialog * myStatsDialog; |
---|
64 | Details * myDetailsDialog; |
---|
65 | QCheckBox * myFileDialogOptionsCheck; |
---|
66 | QSystemTrayIcon myTrayIcon; |
---|
67 | TorrentFilter myFilterModel; |
---|
68 | TorrentDelegate * myTorrentDelegate; |
---|
69 | TorrentDelegateMin * myTorrentDelegateMin; |
---|
70 | Session& mySession; |
---|
71 | Prefs& myPrefs; |
---|
72 | TorrentModel& myModel; |
---|
73 | Ui_MainWindow ui; |
---|
74 | QIcon mySpeedModeOffIcon; |
---|
75 | QIcon mySpeedModeOnIcon; |
---|
76 | time_t myLastSendTime; |
---|
77 | time_t myLastReadTime; |
---|
78 | QTimer myNetworkTimer; |
---|
79 | QTimer myRefreshTrayIconTimer; |
---|
80 | QTimer myRefreshActionSensitivityTimer; |
---|
81 | QAction * myDlimitOffAction; |
---|
82 | QAction * myDlimitOnAction; |
---|
83 | QAction * myUlimitOffAction; |
---|
84 | QAction * myUlimitOnAction; |
---|
85 | QAction * myRatioOffAction; |
---|
86 | QAction * myRatioOnAction; |
---|
87 | |
---|
88 | private: |
---|
89 | QIcon getStockIcon( const QString&, int fallback=-1 ); |
---|
90 | |
---|
91 | private: |
---|
92 | QSet<int> getSelectedTorrents( ) const; |
---|
93 | void updateNetworkIcon( ); |
---|
94 | QWidgetList myHidden; |
---|
95 | |
---|
96 | public slots: |
---|
97 | void openURL( QString ); |
---|
98 | |
---|
99 | private slots: |
---|
100 | void onPrefsDestroyed( ); |
---|
101 | void openPreferences( ); |
---|
102 | void onDetailsDestroyed( ); |
---|
103 | void showTotalRatio( ); |
---|
104 | void showTotalTransfer( ); |
---|
105 | void showSessionRatio( ); |
---|
106 | void showSessionTransfer( ); |
---|
107 | void refreshVisibleCount( ); |
---|
108 | void refreshFreeSpace( ); |
---|
109 | void refreshTitle( ); |
---|
110 | void refreshStatusBar( ); |
---|
111 | void refreshTrayIcon( ); |
---|
112 | void refreshTrayIconSoon( ); |
---|
113 | void openTorrent( ); |
---|
114 | void openURL( ); |
---|
115 | void newTorrent( ); |
---|
116 | void trayActivated( QSystemTrayIcon::ActivationReason ); |
---|
117 | void refreshPref( int key ); |
---|
118 | void addTorrents( const QStringList& filenames ); |
---|
119 | void removeTorrents( const bool deleteFiles ); |
---|
120 | void openDonate( ); |
---|
121 | void openHelp( ); |
---|
122 | void openFolder( ); |
---|
123 | void copyMagnetLinkToClipboard( ); |
---|
124 | void setLocation( ); |
---|
125 | void openProperties( ); |
---|
126 | void toggleSpeedMode( ); |
---|
127 | void dataReadProgress( ); |
---|
128 | void dataSendProgress( ); |
---|
129 | void toggleWindows( bool doShow ); |
---|
130 | void onSetPrefs( ); |
---|
131 | void onSetPrefs( bool ); |
---|
132 | void onSessionSourceChanged( ); |
---|
133 | void onModelReset( ); |
---|
134 | |
---|
135 | private slots: |
---|
136 | void setSortPref ( int ); |
---|
137 | void setSortAscendingPref ( bool ); |
---|
138 | void onSortByActivityToggled ( bool ); |
---|
139 | void onSortByAgeToggled ( bool ); |
---|
140 | void onSortByETAToggled ( bool ); |
---|
141 | void onSortByNameToggled ( bool ); |
---|
142 | void onSortByProgressToggled ( bool ); |
---|
143 | void onSortByQueueToggled ( bool ); |
---|
144 | void onSortByRatioToggled ( bool ); |
---|
145 | void onSortBySizeToggled ( bool ); |
---|
146 | void onSortByStateToggled ( bool ); |
---|
147 | |
---|
148 | private: |
---|
149 | QWidget * myFilterBar; |
---|
150 | |
---|
151 | private: |
---|
152 | QMenu * createOptionsMenu( void ); |
---|
153 | QWidget * createStatusBar( void ); |
---|
154 | QWidget * myStatusBar; |
---|
155 | QPushButton * myAltSpeedButton; |
---|
156 | QAction * myAltSpeedAction; |
---|
157 | QPushButton * myOptionsButton; |
---|
158 | QLabel * myVisibleCountLabel; |
---|
159 | QPushButton * myStatsModeButton; |
---|
160 | QLabel * myStatsLabel; |
---|
161 | QLabel * myDownloadSpeedLabel; |
---|
162 | QLabel * myUploadSpeedLabel; |
---|
163 | QLabel * myFreeSpaceTextLabel; |
---|
164 | QLabel * myFreeSpaceIconLabel; |
---|
165 | QLabel * myNetworkLabel; |
---|
166 | |
---|
167 | public slots: |
---|
168 | void startAll( ); |
---|
169 | void startSelected( ); |
---|
170 | void startSelectedNow( ); |
---|
171 | void pauseAll( ); |
---|
172 | void pauseSelected( ); |
---|
173 | void removeSelected( ); |
---|
174 | void deleteSelected( ); |
---|
175 | void verifySelected( ); |
---|
176 | void queueMoveTop( ); |
---|
177 | void queueMoveUp( ); |
---|
178 | void queueMoveDown( ); |
---|
179 | void queueMoveBottom( ); |
---|
180 | void reannounceSelected( ); |
---|
181 | void addTorrent( const QString& filename ); |
---|
182 | void onNetworkTimer( ); |
---|
183 | |
---|
184 | private: |
---|
185 | void clearSelection( ); |
---|
186 | |
---|
187 | public slots: |
---|
188 | void setToolbarVisible( bool ); |
---|
189 | void setFilterbarVisible( bool ); |
---|
190 | void setStatusbarVisible( bool ); |
---|
191 | void setCompactView( bool ); |
---|
192 | void refreshActionSensitivity( ); |
---|
193 | void refreshActionSensitivitySoon( ); |
---|
194 | void wrongAuthentication( ); |
---|
195 | |
---|
196 | public: |
---|
197 | TrMainWindow( Session&, Prefs&, TorrentModel&, bool minized ); |
---|
198 | virtual ~TrMainWindow( ); |
---|
199 | |
---|
200 | protected: |
---|
201 | virtual void contextMenuEvent( QContextMenuEvent * ); |
---|
202 | virtual void dragEnterEvent( QDragEnterEvent * ); |
---|
203 | virtual void dropEvent( QDropEvent * ); |
---|
204 | }; |
---|
205 | |
---|
206 | #endif |
---|