1 | /* |
---|
2 | * This file Copyright (C) 2009-2015 Mnemosyne LLC |
---|
3 | * |
---|
4 | * It may be used under the GNU GPL versions 2 or 3 |
---|
5 | * or any future license endorsed by Mnemosyne LLC. |
---|
6 | * |
---|
7 | * $Id: MainWindow.h 14537 2015-06-10 21:27:11Z mikedld $ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef QTR_MAIN_WINDOW_H |
---|
11 | #define QTR_MAIN_WINDOW_H |
---|
12 | |
---|
13 | #include <ctime> |
---|
14 | #include <QLineEdit> |
---|
15 | #include <QIcon> |
---|
16 | #include <QMainWindow> |
---|
17 | #include <QMap> |
---|
18 | #include <QPointer> |
---|
19 | #include <QPushButton> |
---|
20 | #include <QSet> |
---|
21 | #include <QSystemTrayIcon> |
---|
22 | #include <QTimer> |
---|
23 | #include <QWidgetList> |
---|
24 | #include <QNetworkReply> |
---|
25 | |
---|
26 | #include "Filters.h" |
---|
27 | #include "TorrentFilter.h" |
---|
28 | #include "ui_MainWindow.h" |
---|
29 | |
---|
30 | class AddData; |
---|
31 | class ActionDelegator; |
---|
32 | class Prefs; |
---|
33 | class DetailsDialog; |
---|
34 | class Session; |
---|
35 | class TorrentDelegate; |
---|
36 | class TorrentDelegateMin; |
---|
37 | class TorrentModel; |
---|
38 | class QAction; |
---|
39 | class QLabel; |
---|
40 | class QMenu; |
---|
41 | class QModelIndex; |
---|
42 | class QSortFilterProxyModel; |
---|
43 | class Filterbar; |
---|
44 | |
---|
45 | extern "C" |
---|
46 | { |
---|
47 | struct tr_variant; |
---|
48 | } |
---|
49 | |
---|
50 | class MainWindow: 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 | QPointer<QDialog> myPrefsDialog; |
---|
62 | QDialog * myAboutDialog; |
---|
63 | QDialog * myStatsDialog; |
---|
64 | DetailsDialog * myDetailsDialog; |
---|
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 | time_t myLastSendTime; |
---|
74 | time_t myLastReadTime; |
---|
75 | QTimer myNetworkTimer; |
---|
76 | bool myNetworkError; |
---|
77 | QTimer myRefreshTrayIconTimer; |
---|
78 | QTimer myRefreshActionSensitivityTimer; |
---|
79 | QAction * myDlimitOffAction; |
---|
80 | QAction * myDlimitOnAction; |
---|
81 | QAction * myUlimitOffAction; |
---|
82 | QAction * myUlimitOnAction; |
---|
83 | QAction * myRatioOffAction; |
---|
84 | QAction * myRatioOnAction; |
---|
85 | |
---|
86 | private: |
---|
87 | QIcon getStockIcon (const QString&, int fallback=-1); |
---|
88 | |
---|
89 | private: |
---|
90 | QSet<int> getSelectedTorrents () const; |
---|
91 | void updateNetworkIcon (); |
---|
92 | QWidgetList myHidden; |
---|
93 | |
---|
94 | private slots: |
---|
95 | void openPreferences (); |
---|
96 | void onDetailsDestroyed (); |
---|
97 | void showTotalRatio (); |
---|
98 | void showTotalTransfer (); |
---|
99 | void showSessionRatio (); |
---|
100 | void showSessionTransfer (); |
---|
101 | void refreshTitle (); |
---|
102 | void refreshStatusBar (); |
---|
103 | void refreshTrayIcon (); |
---|
104 | void refreshTrayIconSoon (); |
---|
105 | void openTorrent (); |
---|
106 | void openURL (); |
---|
107 | void newTorrent (); |
---|
108 | void trayActivated (QSystemTrayIcon::ActivationReason); |
---|
109 | void refreshPref (int key); |
---|
110 | void addTorrents (const QStringList& filenames); |
---|
111 | void removeTorrents (const bool deleteFiles); |
---|
112 | void openDonate (); |
---|
113 | void openHelp (); |
---|
114 | void openFolder (); |
---|
115 | void copyMagnetLinkToClipboard (); |
---|
116 | void setLocation (); |
---|
117 | void openProperties (); |
---|
118 | void toggleSpeedMode (); |
---|
119 | void dataReadProgress (); |
---|
120 | void dataSendProgress (); |
---|
121 | void onError (QNetworkReply::NetworkError); |
---|
122 | void errorMessage (const QString&); |
---|
123 | void toggleWindows (bool doShow); |
---|
124 | void onSetPrefs (); |
---|
125 | void onSetPrefs (bool); |
---|
126 | void onSessionSourceChanged (); |
---|
127 | void onModelReset (); |
---|
128 | |
---|
129 | private slots: |
---|
130 | void setSortPref (int); |
---|
131 | void setSortAscendingPref (bool); |
---|
132 | void onSortByActivityToggled (bool); |
---|
133 | void onSortByAgeToggled (bool); |
---|
134 | void onSortByETAToggled (bool); |
---|
135 | void onSortByNameToggled (bool); |
---|
136 | void onSortByProgressToggled (bool); |
---|
137 | void onSortByQueueToggled (bool); |
---|
138 | void onSortByRatioToggled (bool); |
---|
139 | void onSortBySizeToggled (bool); |
---|
140 | void onSortByStateToggled (bool); |
---|
141 | |
---|
142 | private: |
---|
143 | QWidget * myFilterBar; |
---|
144 | |
---|
145 | private: |
---|
146 | QMenu * createOptionsMenu (); |
---|
147 | QMenu * createStatsModeMenu (); |
---|
148 | void initStatusBar (); |
---|
149 | |
---|
150 | QAction * myAltSpeedAction; |
---|
151 | QString myErrorMessage; |
---|
152 | |
---|
153 | public slots: |
---|
154 | void startAll (); |
---|
155 | void startSelected (); |
---|
156 | void startSelectedNow (); |
---|
157 | void pauseAll (); |
---|
158 | void pauseSelected (); |
---|
159 | void removeSelected (); |
---|
160 | void deleteSelected (); |
---|
161 | void verifySelected (); |
---|
162 | void queueMoveTop (); |
---|
163 | void queueMoveUp (); |
---|
164 | void queueMoveDown (); |
---|
165 | void queueMoveBottom (); |
---|
166 | void reannounceSelected (); |
---|
167 | void onNetworkTimer (); |
---|
168 | |
---|
169 | private: |
---|
170 | void clearSelection (); |
---|
171 | void addTorrent (const AddData& addMe, bool showOptions); |
---|
172 | |
---|
173 | public slots: |
---|
174 | void setToolbarVisible (bool); |
---|
175 | void setFilterbarVisible (bool); |
---|
176 | void setStatusbarVisible (bool); |
---|
177 | void setCompactView (bool); |
---|
178 | void refreshActionSensitivity (); |
---|
179 | void refreshActionSensitivitySoon (); |
---|
180 | void wrongAuthentication (); |
---|
181 | |
---|
182 | public: |
---|
183 | MainWindow (Session&, Prefs&, TorrentModel&, bool minized); |
---|
184 | virtual ~MainWindow (); |
---|
185 | |
---|
186 | protected: |
---|
187 | virtual void contextMenuEvent (QContextMenuEvent *); |
---|
188 | virtual void dragEnterEvent (QDragEnterEvent *); |
---|
189 | virtual void dropEvent (QDropEvent *); |
---|
190 | }; |
---|
191 | |
---|
192 | #endif // QTR_MAIN_WINDOW_H |
---|