summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/kopetewindow.h
blob: 7d881c79ae051e16f88d19d56f82fc37c2c7a9a0 (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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/*
    kopetewindow.h  -  Kopete Main Window

    Copyright (c) 2001-2002 by Duncan Mac-Vicar Prett <duncan@kde.org>
    Copyright (c) 2001-2002 by Stefan Gehn            <metz AT gehn.net>
    Copyright (c) 2002-2003 by Martijn Klingens       <klingens@kde.org>

    Kopete    (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.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.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef KOPETEWINDOW_H
#define KOPETEWINDOW_H

#include <tqptrdict.h>

#include <kmainwindow.h>
#include <tqlabel.h>

class TQHBox;
class TQTimer;
class TQSignalMapper;

class TQMouseEvent;
class TQPoint;

class KAction;
class KActionMenu;

class KGlobalAccel;
class KSelectAction;
class KSqueezedTextLabel;
class KToggleAction;

class KopeteAccountStatusBarIcon;
class KopeteContactListView;
class KopetePluginConfig;
class KopeteSystemTray;
class KopeteEditGlobalIdentityWidget;

namespace Kopete
{
class AwayAction;
class Account;
class Contact;
class Plugin;
class Protocol;
}

/**
 * @author Duncan Mac-Vicar P. <duncan@kde.org>
 */
class KopeteWindow : public KMainWindow
{
	Q_OBJECT
  TQ_OBJECT

public:
	KopeteWindow ( TQWidget *parent = 0, const char *name = 0 );
	~KopeteWindow();

	virtual bool eventFilter( TQObject* o, TQEvent* e );

protected:
	virtual void closeEvent( TQCloseEvent *ev );
	virtual void leaveEvent( TQEvent* ev );
	virtual void showEvent( TQShowEvent* ev );

private slots:
	void showMenubar();
	void showStatusbar();
	void slotToggleShowOffliners();
	void slotToggleShowEmptyGroups();
	void slotConfigChanged();
	void slotConfNotifications();
	void slotConfToolbar();
	void slotUpdateToolbar();
	void slotConfigurePlugins();
	void slotConfGlobalKeys();
	void slotShowHide();
	void slotToggleAway();

	/* show the global status message selector menu
	 */
	void setStatusMessage( const TQString & );
	
	/**
	 * Checks if the mousecursor is in the contact list.
	 * If not, the window will be hidden.
	 */
	void slotAutoHide();

	/**
	 * This slot will apply settings that change the
	 * contactlist's appearance. Only autohiding is
	 * handled here at the moment
	 */
	void slotContactListAppearanceChanged();

	/**
	 * This slot will set all the protocols to away
	 */
	void slotGlobalAway();
	void slotGlobalBusy();
	void slotGlobalAvailable();
	void slotSetInvisibleAll();
	void slotDisconnectAll();

	void slotQuit();

	/**
	 * Get a notification when a plugin is loaded, so we can merge
	 * XMLGUI cruft
	 */
	void slotPluginLoaded( Kopete::Plugin *p );

	/**
	 * Get a notification when an account is created, so we can add a status bar
	 * icon
	 */
	void slotAccountRegistered( Kopete::Account *a );

	/**
	 * Cleanup the status bar icon when the account is destroyed
	 */
	void slotAccountUnregistered( const Kopete::Account *a);

	/**
	 * The status icon got changed, update it.
	 * @param contact The account's contact that changed.
	 */
	void slotAccountStatusIconChanged( Kopete::Contact * contact);

	/**
	 * The status icon of some account changed. Must be sent by the account in question.
	 */
	void slotAccountStatusIconChanged();

	/**
	 * Show a context menu for a protocol
	 */
//	void slotProtocolStatusIconRightClicked( Kopete::Protocol *proto, const TQPoint &p );

	/**
	 * Show a context menu for an account
	 */
	void slotAccountStatusIconRightClicked( Kopete::Account *a,
		const TQPoint &p );

	void slotTrayAboutToShowMenu(KPopupMenu *);

	/**
	 * Show the Add Contact wizard
	 */
	void showAddContactDialog( Kopete::Account * );

	/**
	 * Show the Export Contacts wizards
	 */
	void showExportDialog();

	/**
	 * Enable the Connect All and Disconnect All buttons here
	 * along with connecting the accountRegistered and accountUnregistered
	 * signals.
	 */
	void slotAllPluginsLoaded();
	
	/**
	 * Protected slot to setup the Set Global tqStatus Message menu.
	 */
	void slotBuildStatusMessageMenu();
	void slotStatusMessageSelected( int i );
	void slotNewStatusMessageEntered();

        /**
         * Show the set global status message menu when clicking on the icon in the status bar.
         */
        void slotGlobalStatusMessageIconClicked( const TQPoint &position );

	/**
	 * Extracts protocolId and accountId from the single TQString argument signalled by a TQSignalMapper,
	 * get the account, and call showAddContactDialog.
	 * @param accountIdentifer TQString of protocolId and accountId, concatenated with TQChar( 0xE000 )
	 * We need both to uniquely identify an account, but TQSignalMapper only emits one TQString.
	 */
	void slotAddContactDialogInternal( const TQString & accountIdentifier );
	
public:
	KopeteContactListView *contactlist;

	// Some Actions
	KActionMenu* actionAddContact;

	//KActionMenu* actionConnectionMenu;
	//KAction* actionConnect;
	KAction* actionDisconnect;
	KAction* actionExportContacts;

	KActionMenu* actionAwayMenu;
	KActionMenu* actionDockMenu;
	KAction* selectAway;
	KAction* selectBusy;
	KAction* actionSetAvailable;
	KAction* actionSetInvisible;


	KAction* actionPrefs;
	KAction* actionQuit;
	KAction* actionSave;
	KToggleAction *menubarAction;
	KToggleAction *statusbarAction;
	KToggleAction *actionShowOffliners;
	KToggleAction *actionShowEmptyGroups;
	KGlobalAccel *globalAccel;

	KopeteEditGlobalIdentityWidget *editGlobalIdentityWidget;
private:
	void initView();
	void initActions();
	void initSystray();
	void loadOptions();
	void saveOptions();

	void makeTrayToolTip();
	void startAutoHideTimer();

	virtual bool queryClose();
	virtual bool queryExit();
private:
	int docked;
	bool hidden;
	int deskRight;
	TQPoint position;
	TQHBox *m_statusBarWidget;
	KopeteSystemTray *m_tray;
	bool m_autoHide;
	unsigned int m_autoHideTimeout;
	TQTimer* m_autoHideTimer;
	TQSignalMapper* addContactMapper;

	KopetePluginConfig *m_pluginConfig;

	/**
	 * This is really a dictionary of KopeteAccountStatusBarIcon objects, but
	 * TQPtrDict requires a full class definition to be known to make
	 * that work. And since I don't want to include that whole file here,
	 * use TQObject instead.
	 */
	TQPtrDict<TQObject> m_accountStatusBarIcons;
	KSqueezedTextLabel * m_globalStatusMessage;
	KPopupMenu * m_globalStatusMessageMenu;
	TQLineEdit * m_newMessageEdit;
	TQString m_globalStatusMessageStored;
};


class GlobalStatusMessageIconLabel : public TQLabel
{
      Q_OBJECT
  TQ_OBJECT
public:
      GlobalStatusMessageIconLabel(TQWidget *parent = 0, const char *name = 0);

protected:
      void mouseReleaseEvent(TQMouseEvent *event);

signals:
      void iconClicked(const TQPoint &position);

};

#endif
// vim: set noet ts=4 sts=4 sw=4: