summaryrefslogtreecommitdiffstats
path: root/kdelirc/irkick/irkick.h
blob: bdcb57ea1f195bc5cd1b0cc213cd8d80ae075609 (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
/***************************************************************************
                          irkick.h  -  Interface of the main window
    copyright            : (C) 2002 by Gav Wood
    email                : gav@kde.org

***************************************************************************/

// This program is free software.

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef __IRKICK_H
#define __IRKICK_H

#include <tqstring.h>

#include <ksystemtray.h>
#include <kdedmodule.h>
#include <kaboutdata.h>

#include <dcopobject.h>

#include "modes.h"
#include "iractions.h"
#include "klircclient.h"

class QMouseEvent;

class IRKTrayIcon: public KSystemTray
{
	void mousePressEvent(TQMouseEvent *e);

public:
	KPopupMenu* contextMenu() const { return KSystemTray::contextMenu(); }
	KActionCollection* actionCollection() { return KSystemTray::actionCollection(); }

	IRKTrayIcon(TQWidget *parent = 0, const char *name = 0): KSystemTray(parent, name) {}
};

class IRKick: public TQObject, public DCOPObject
{
	Q_OBJECT
	K_DCOP

	TQString npApp, npModule, npMethod;
	TQMap<TQString, TQString> currentModes;
	TQMap<TQString, IRKTrayIcon *> currentModeIcons;
	IRActions allActions;
	int theResetCount;
	Modes allModes;

	IRKTrayIcon *theTrayIcon;
	KAboutData *aboutData;
	TQTimer *theFlashOff;

	void updateModeIcons();

protected:
	KLircClient *theClient;

k_dcop:
	/**
	 * Query status of connection.
	 *
	 * @returns true if connected to lircd.
	 */
	virtual bool isConnected() { return theClient->isConnected(); }

	/**
	 * Query status of remote list.
	 *
	 * Make sure this is true before calling remotes()/buttons(...).
	 *
	 * @returns true if up to date.
	 */
	virtual bool haveFullList() { return theClient->haveFullList(); }

	/**
	 * Retrieve list of remote controls.
	 *
	 * @returns said list.
	 */
	virtual const TQStringList remotes() { return theClient->remotes(); }

	/**
	 * Retrieve list of buttons of a praticular remote control.
	 *
	 * @returns said list.
	 */
	virtual const TQStringList buttons(TQString theRemote) { return theClient->buttons(theRemote); }

	/**
	 * Sends next keypress to given application by DCOP.
	 *
	 * @param The receiving application.
	 * @param The receiving application module.
	 * @param The method name. Must have two TQString parameters.
	 */
	virtual void stealNextPress(TQString app, TQString module, TQString method);

	/**
	 * Cancels the proceedings of the previous stealNextPress call, if any.
	 */
	virtual void dontStealNextPress();

	/**
	 * Reloads configuration from file(s)
	 */
	virtual void reloadConfiguration() { slotReloadConfiguration(); }

private slots:
	void gotMessage(const TQString &theRemote, const TQString &theButton, int theRepeatCounter);
	void resetModes();
	void doQuit();
	void flashOff();
	void checkLirc();

	void slotConfigure();
	void slotReloadConfiguration();
	void slotClosed();
private:
	void executeAction(const IRAction &action);
	bool getPrograms(const IRAction &action, TQStringList &populous);

public:
	IRKick(const TQCString &obj);
	virtual ~IRKick();
};

#endif