1 | /* This file is part of the KDE project |
2 | |
3 | Copyright (C) 2002 by Patrick Charbonnier <pch@freeshell.org> |
4 | Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss |
5 | Copyright (C) 2006 Dario Massarin <nekkar@libero.it> |
6 | Copyright (C) 2009 - 2010 Matthias Fuchs <mat69@gmx.net> |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public |
10 | License as published by the Free Software Foundation; either |
11 | version 2 of the License, or (at your option) any later version. |
12 | */ |
13 | |
14 | #ifndef MAINWINDOW_H |
15 | #define MAINWINDOW_H |
16 | |
17 | #include <ktoggleaction.h> |
18 | #include <kxmlguiwindow.h> |
19 | #include <kurl.h> |
20 | |
21 | #include <kstatusnotifieritem.h> |
22 | #include "ui/tray.h" |
23 | #include "core/transfer.h" |
24 | #include "core/transfergroup.h" |
25 | |
26 | #ifdef HAVE_QCA2 |
27 | #include <QtCrypto> |
28 | #endif |
29 | |
30 | class ViewsContainer; |
31 | class DropTarget; |
32 | class DBusKgetWrapper; |
33 | class HttpServer; |
34 | class KGet; |
35 | |
36 | /** |
37 | * The main window of KGet. |
38 | * |
39 | * Can be collapsed or expanded. |
40 | */ |
41 | class MainWindow : public KXmlGuiWindow |
42 | { |
43 | friend class DBusKGetWrapper; |
44 | |
45 | Q_OBJECT |
46 | public: |
47 | explicit MainWindow(bool showMainwindow = true, bool startWithoutAnimation = false, bool doTesting = false, QWidget *parent = 0); |
48 | ~MainWindow(); |
49 | |
50 | virtual void setSystemTrayDownloading(bool running); |
51 | |
52 | //no slot, to make sure that MainWindow is correctly initialized before any transfers get added |
53 | void init(); |
54 | |
55 | public slots: |
56 | void slotQuit(); |
57 | void slotImportUrl(const QString &url); |
58 | void slotUpdateTitlePercent(); |
59 | |
60 | protected: |
61 | // ignore/accept quit events |
62 | virtual void closeEvent(QCloseEvent *); |
63 | virtual void hideEvent(QHideEvent *); |
64 | virtual void showEvent(QShowEvent *); |
65 | |
66 | // drag and drop |
67 | virtual void dragEnterEvent(QDragEnterEvent *); |
68 | virtual void dropEvent(QDropEvent *); |
69 | |
70 | // set sensitive initial size |
71 | virtual QSize sizeHint() const; |
72 | |
73 | private slots: |
74 | // slots connected to actions |
75 | void slotToggleDropTarget(); |
76 | void slotNewTransfer(); |
77 | void slotImportTransfers(); |
78 | void slotExportTransfers(); |
79 | void slotPreferences(); |
80 | void slotDeleteGroup(); |
81 | void slotRenameGroup(); |
82 | void slotSetIconGroup(); |
83 | void slotStartDownload(); |
84 | void slotStopDownload(); |
85 | void slotConfigureNotifications(); |
86 | void slotToggleAutoPaste(); |
87 | void slotTrayKonquerorIntegration(bool); |
88 | void slotKonquerorIntegration( bool ); |
89 | void slotShowMenubar(); |
90 | void slotTransferGroupSettings(); |
91 | void slotTransferSettings(); |
92 | void slotCreateMetalink(); |
93 | void slotPriorityTop(); |
94 | void slotPriorityBottom(); |
95 | void slotPriorityUp(); |
96 | void slotPriorityDown(); |
97 | void slotDownloadFinishedActions(); |
98 | |
99 | // transfers slots |
100 | void slotStopAllDownload(); |
101 | void slotStopSelectedDownload(); |
102 | void slotStartAllDownload(); |
103 | void slotStartSelectedDownload(); |
104 | void slotDeleteSelected(); |
105 | void slotDeleteSelectedIncludingFiles(); |
106 | void slotRedownloadSelected(); |
107 | void slotTransfersOpenDest(); |
108 | void slotTransfersOpenFile(); |
109 | void slotTransfersShowDetails(); |
110 | void slotTransfersCopySourceUrl(); |
111 | void slotDeleteFinished(); |
112 | |
113 | // misc slots |
114 | void slotSaveMyself(); |
115 | void slotNewToolbarConfig(); |
116 | void slotNewConfig(); |
117 | void slotCheckClipboard(); |
118 | void slotTransferHistory(); |
119 | |
120 | // import links slots |
121 | void slotShowListLinks(); |
122 | |
123 | //Model changes |
124 | void slotTransfersChanged(QMap<TransferHandler*, Transfer::ChangesFlags> transfers); |
125 | void slotGroupsChanged(QMap<TransferGroupHandler*, TransferGroup::ChangesFlags> groups); |
126 | |
127 | private: |
128 | /** |
129 | * Returns the completed percents of all active transfers |
130 | */ |
131 | int transfersPercent(); |
132 | |
133 | // one-time functions |
134 | void setupActions(); |
135 | |
136 | KGet * m_kget; |
137 | |
138 | // internal widgets |
139 | ViewsContainer * m_viewsContainer; |
140 | |
141 | // separated widgets |
142 | DropTarget * m_drop; |
143 | Tray * m_dock; |
144 | |
145 | // actions |
146 | KToggleAction * m_autoPasteAction; |
147 | KToggleAction * m_menubarAction; |
148 | KToggleAction * m_konquerorIntegration; |
149 | |
150 | // for autopaste function |
151 | QString lastClipboard; |
152 | // timer for checking clipboard - autopaste function |
153 | QTimer *clipboardTimer; |
154 | |
155 | bool m_startWithoutAnimation; |
156 | bool m_doTesting; // UnitTest flag |
157 | |
158 | HttpServer *m_webinterface; |
159 | |
160 | #ifdef HAVE_QCA2 |
161 | QCA::Initializer m_qcaInit; |
162 | #endif //HAVE_QCA2 |
163 | }; |
164 | |
165 | #endif |
166 | |