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 14539 2015-06-12 22:12:12Z mikedld $ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef QTR_MAIN_WINDOW_H |
---|
11 | #define QTR_MAIN_WINDOW_H |
---|
12 | |
---|
13 | #include <ctime> |
---|
14 | |
---|
15 | #include <QMainWindow> |
---|
16 | #include <QNetworkReply> |
---|
17 | #include <QPointer> |
---|
18 | #include <QSet> |
---|
19 | #include <QSystemTrayIcon> |
---|
20 | #include <QTimer> |
---|
21 | #include <QWidgetList> |
---|
22 | |
---|
23 | #include "Filters.h" |
---|
24 | #include "TorrentFilter.h" |
---|
25 | #include "ui_MainWindow.h" |
---|
26 | |
---|
27 | class QAction; |
---|
28 | class QIcon; |
---|
29 | class QMenu; |
---|
30 | |
---|
31 | class AddData; |
---|
32 | class Prefs; |
---|
33 | class DetailsDialog; |
---|
34 | class Session; |
---|
35 | class TorrentDelegate; |
---|
36 | class TorrentDelegateMin; |
---|
37 | class TorrentModel; |
---|
38 | |
---|
39 | extern "C" |
---|
40 | { |
---|
41 | struct tr_variant; |
---|
42 | } |
---|
43 | |
---|
44 | class MainWindow: public QMainWindow |
---|
45 | { |
---|
46 | Q_OBJECT |
---|
47 | |
---|
48 | public: |
---|
49 | MainWindow (Session&, Prefs&, TorrentModel&, bool minized); |
---|
50 | virtual ~MainWindow (); |
---|
51 | |
---|
52 | public slots: |
---|
53 | void startAll (); |
---|
54 | void startSelected (); |
---|
55 | void startSelectedNow (); |
---|
56 | void pauseAll (); |
---|
57 | void pauseSelected (); |
---|
58 | void removeSelected (); |
---|
59 | void deleteSelected (); |
---|
60 | void verifySelected (); |
---|
61 | void queueMoveTop (); |
---|
62 | void queueMoveUp (); |
---|
63 | void queueMoveDown (); |
---|
64 | void queueMoveBottom (); |
---|
65 | void reannounceSelected (); |
---|
66 | void onNetworkTimer (); |
---|
67 | |
---|
68 | void setToolbarVisible (bool); |
---|
69 | void setFilterbarVisible (bool); |
---|
70 | void setStatusbarVisible (bool); |
---|
71 | void setCompactView (bool); |
---|
72 | void refreshActionSensitivity (); |
---|
73 | void refreshActionSensitivitySoon (); |
---|
74 | void wrongAuthentication (); |
---|
75 | |
---|
76 | protected: |
---|
77 | // QWidget |
---|
78 | virtual void contextMenuEvent (QContextMenuEvent *); |
---|
79 | virtual void dragEnterEvent (QDragEnterEvent *); |
---|
80 | virtual void dropEvent (QDropEvent *); |
---|
81 | |
---|
82 | private: |
---|
83 | QIcon getStockIcon (const QString&, int fallback = -1); |
---|
84 | |
---|
85 | QSet<int> getSelectedTorrents () const; |
---|
86 | void updateNetworkIcon (); |
---|
87 | |
---|
88 | QMenu * createOptionsMenu (); |
---|
89 | QMenu * createStatsModeMenu (); |
---|
90 | void initStatusBar (); |
---|
91 | |
---|
92 | void clearSelection (); |
---|
93 | void addTorrent (const AddData& addMe, bool showOptions); |
---|
94 | |
---|
95 | // QWidget |
---|
96 | virtual void hideEvent (QHideEvent * event); |
---|
97 | virtual void showEvent (QShowEvent * event); |
---|
98 | |
---|
99 | private slots: |
---|
100 | void openPreferences (); |
---|
101 | void onDetailsDestroyed (); |
---|
102 | void showTotalRatio (); |
---|
103 | void showTotalTransfer (); |
---|
104 | void showSessionRatio (); |
---|
105 | void showSessionTransfer (); |
---|
106 | void refreshTitle (); |
---|
107 | void refreshStatusBar (); |
---|
108 | void refreshTrayIcon (); |
---|
109 | void refreshTrayIconSoon (); |
---|
110 | void openTorrent (); |
---|
111 | void openURL (); |
---|
112 | void newTorrent (); |
---|
113 | void trayActivated (QSystemTrayIcon::ActivationReason); |
---|
114 | void refreshPref (int key); |
---|
115 | void addTorrents (const QStringList& filenames); |
---|
116 | void removeTorrents (const bool deleteFiles); |
---|
117 | void openDonate (); |
---|
118 | void openHelp (); |
---|
119 | void openFolder (); |
---|
120 | void copyMagnetLinkToClipboard (); |
---|
121 | void setLocation (); |
---|
122 | void openProperties (); |
---|
123 | void toggleSpeedMode (); |
---|
124 | void dataReadProgress (); |
---|
125 | void dataSendProgress (); |
---|
126 | void onError (QNetworkReply::NetworkError); |
---|
127 | void errorMessage (const QString&); |
---|
128 | void toggleWindows (bool doShow); |
---|
129 | void onSetPrefs (); |
---|
130 | void onSetPrefs (bool); |
---|
131 | void onSessionSourceChanged (); |
---|
132 | void onModelReset (); |
---|
133 | |
---|
134 | void setSortPref (int); |
---|
135 | void setSortAscendingPref (bool); |
---|
136 | void onSortByActivityToggled (bool); |
---|
137 | void onSortByAgeToggled (bool); |
---|
138 | void onSortByETAToggled (bool); |
---|
139 | void onSortByNameToggled (bool); |
---|
140 | void onSortByProgressToggled (bool); |
---|
141 | void onSortByQueueToggled (bool); |
---|
142 | void onSortByRatioToggled (bool); |
---|
143 | void onSortBySizeToggled (bool); |
---|
144 | void onSortByStateToggled (bool); |
---|
145 | |
---|
146 | private: |
---|
147 | Session& mySession; |
---|
148 | Prefs& myPrefs; |
---|
149 | TorrentModel& myModel; |
---|
150 | |
---|
151 | Ui_MainWindow ui; |
---|
152 | |
---|
153 | time_t myLastFullUpdateTime; |
---|
154 | QDialog * mySessionDialog; |
---|
155 | QPointer<QDialog> myPrefsDialog; |
---|
156 | QDialog * myAboutDialog; |
---|
157 | QDialog * myStatsDialog; |
---|
158 | DetailsDialog * myDetailsDialog; |
---|
159 | QSystemTrayIcon myTrayIcon; |
---|
160 | TorrentFilter myFilterModel; |
---|
161 | TorrentDelegate * myTorrentDelegate; |
---|
162 | TorrentDelegateMin * myTorrentDelegateMin; |
---|
163 | time_t myLastSendTime; |
---|
164 | time_t myLastReadTime; |
---|
165 | QTimer myNetworkTimer; |
---|
166 | bool myNetworkError; |
---|
167 | QTimer myRefreshTrayIconTimer; |
---|
168 | QTimer myRefreshActionSensitivityTimer; |
---|
169 | QAction * myDlimitOffAction; |
---|
170 | QAction * myDlimitOnAction; |
---|
171 | QAction * myUlimitOffAction; |
---|
172 | QAction * myUlimitOnAction; |
---|
173 | QAction * myRatioOffAction; |
---|
174 | QAction * myRatioOnAction; |
---|
175 | QWidgetList myHidden; |
---|
176 | QWidget * myFilterBar; |
---|
177 | QAction * myAltSpeedAction; |
---|
178 | QString myErrorMessage; |
---|
179 | }; |
---|
180 | |
---|
181 | #endif // QTR_MAIN_WINDOW_H |
---|