summaryrefslogtreecommitdiffstats
path: root/kget/tdemainwidget.h
blob: cd8703d6fae5d4b56dec174027ebf35f833e6771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/***************************************************************************
*                                tdemainwidget.h
*                             -------------------
*
*    Revision     : $Id$
*    begin        : Tue Jan 29 2002
*    copyright    : (C) 2002 by Patrick Charbonnier
*                 : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss
*    email        : pch@freeshell.org
*
****************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 ***************************************************************************/


#ifndef _KMAINWIDGET_H_
#define _KMAINWIDGET_H_

#include <tdemainwindow.h>
#include <tdeaction.h>
#include <kurl.h>
#include "common.h"

#include "kget_iface.h"

class TDEAction;
//class TDEToggleAction;
class TDERadioAction;

class DockWidget;
class DropTarget;
class LogWindow;
class DlgPreferences;

class Transfer;
class TransferList;
class Settings;


class TDEMainWidget:public TDEMainWindow, virtual public KGetIface
{

  Q_OBJECT
  

public:
    enum StatusbarFields { ID_TOTAL_TRANSFERS = 1, ID_TOTAL_FILES, ID_TOTAL_SIZE,
                           ID_TOTAL_TIME         , ID_TOTAL_SPEED                };

    TDEMainWidget(bool bShowMain = false);
    ~TDEMainWidget();

    void addTransfer( const TQString& src );
    void addTransferEx( const KURL& url,
                        const KURL& destFile = KURL());

    // dcop interface
    virtual void addTransfers( const KURL::List& src, const TQString& destDir = TQString() );
    virtual bool isDropTargetVisible() const;
    virtual void setDropTargetVisible( bool setVisible );

    
    void checkQueue();

    void setListFont();
    void setAutoSave();
    void setAutoDisconnect();

    LogWindow *logwin()const { return logWindow;}
    friend class Settings;

    // Actions
    TDEToggleAction *m_paShowLog;
    TDEToggleAction *m_menubarAction;
    TDEAction *m_paPreferences;
    TDEAction *m_paQuit;
    bool b_viewLogWindow;

    void readTransfersEx(const KURL & url);

    void activateDropTarget();

public slots:
    void slotPasteTransfer();
    void slotToggleLogWindow();
    void slotPreferences();
    void slotConfigureNotifications();
    void slotToggleExpertMode();
    void slotToggleOfflineMode();
    void slotToggleUseLastDir();
    void slotToggleAutoDisconnect();
    void slotToggleAutoShutdown();
    void slotToggleAutoPaste();
    void slotToggleDropTarget();
    void slotToggleAnimation();
    void slotUpdateActions();
    void slotKonquerorIntegration();

protected slots:
    void slotQuit();

    void slotOpenTransfer();
    void slotExportTransfers();
    void slotImportTransfers();
    void slotImportTextFile();

    void slotSaveYourself();
    void slotCheckConnection();


    void slotStatusChanged(Transfer * item, int _operation);

    void slotResumeCurrent();
    void slotPauseCurrent();
    void slotDeleteCurrent();
    void slotRestartCurrent();

    void slotQueueCurrent();
    void slotTimerCurrent();
    void slotDelayCurrent();

    void slotOpenIndividual();

    void slotAnimTimeout();
    void slotTransferTimeout();
    void slotAutosaveTimeout();

    void slotMoveToBegin();
    void slotMoveToEnd();

    void slotCopyToClipboard();
    void slotCheckClipboard();

    void slotConfigureToolbars();
    void slotNewToolbarConfig();
    void slotShowMenubar();

    void slotPopupMenu(Transfer * item);

protected:
    virtual void setOfflineMode( bool online );
    virtual bool isOfflineMode() const;
    virtual bool queryClose();
    void writeLog();

    // drag and drop
    virtual void dragEnterEvent(TQDragEnterEvent *);
    virtual void dropEvent(TQDropEvent *);

    void readTransfers(bool ask_for_name = false);
    void writeTransfers(bool ask_for_name = false);


    void setupGUI();
    void setupWhatsThis();

    void updateStatusBar();

    // some flags
    bool b_connected;
    bool b_viewPreferences;

    // utility functions
    void onlineDisconnect();
    void checkOnline();
    void stopAll();
    void log(const TQString & message, bool statusbar = true);

    /** No descriptions */
    virtual void customEvent(TQCustomEvent * e);

    // various timers
    TQTimer *animTimer;          // animation timer
    TQTimer *connectionTimer;    // timer that checks whether we are online
    TQTimer *transferTimer;      // timer for scheduled transfers
    TQTimer *autosaveTimer;      // timer for autosaving transfer list
    TQTimer *clipboardTimer;     // timer for checking clipboard - autopaste function

    TQString logFileName;



private:
    TQString getSaveDirectoryFor( const TQString& filename ) const;
    bool sanityChecksSuccessful( const KURL& url );

    TransferList * myTransferList;
    KHelpMenu *menuHelp;

    LogWindow *logWindow;
    DlgPreferences *prefDlg;
    DockWidget *kdock;

    TQString lastClipboard;

    uint animCounter;

    int _sock;

    // Actions
    TDEAction *m_paOpenTransfer, *m_paPasteTransfer, *m_paExportTransfers, *m_paImportTransfers;
    TDEAction *m_paImportText;

    TDEAction *m_paMoveToBegin, *m_paMoveToEnd, *m_paCopy, *m_paIndividual;
    TDEAction *m_paResume, *m_paPause, *m_paDelete, *m_paRestart;
    TDERadioAction *m_paQueue, *m_paTimer, *m_paDelay;

    TDEToggleAction *m_paUseAnimation;
    TDEToggleAction *m_paExpertMode, *m_paUseLastDir, *m_paOfflineMode;
    TDEToggleAction *m_paAutoDisconnect, *m_paAutoShutdown, *m_paAutoPaste;

    TDEAction *m_paDropTarget;
    TDEAction *m_paKonquerorIntegration;
    bool m_showDropTarget;

};

extern TDEMainWidget *tdemain;
extern DropTarget *kdrop;

#endif                          // _KMAINWIDGET_H_