summaryrefslogtreecommitdiffstats
path: root/kxkb/kxkbtraywindow.h
blob: 38e42db5daa9e244960eca6b8db6ab22d423cea4 (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
//
// C++ Interface: kxkbtraywindow
//
// Description: 
//
//
// Author: Andriy Rysin <rysin@kde.org>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef KXKBSYSTEMTRAY_H
#define KXKBSYSTEMTRAY_H

#include <ksystemtray.h>

#include <tqstring.h>
#include <tqvaluelist.h>

#include "kxkbconfig.h"


class TQLabel;
class TQPopupMenu;
class XkbRules;

/* This class is responsible for displaying flag/label for the layout,
    catching keyboard/mouse events and displaying menu when selected
*/

class KxkbLabelController: public QObject
{
// 	Q_OBJECT
			
public:
	enum { START_MENU_ID = 100, CONFIG_MENU_ID = 130, HELP_MENU_ID = 131 };

    KxkbLabelController(TQLabel *label, TQPopupMenu* contextMenu);

    void initLayoutList(const TQValueList<LayoutUnit>& layouts, const XkbRules& rule);
    void setCurrentLayout(const LayoutUnit& layout);
// 	void setCurrentLayout(const TQString& layout, const TQString &variant);
	void setError(const TQString& layoutInfo="");
    void setShowFlag(bool showFlag) { m_showFlag = showFlag; }
	void show() { label->show(); }
	
// signals:
// 
// 	void menuActivated(int);
//     void toggled();

// protected:
// 
//     void mouseReleaseEvent(TQMouseEvent *);

private:
	TQLabel* label;
	TQPopupMenu* contextMenu;
	
	const int m_menuStartIndex;
	bool m_showFlag;
	int m_prevLayoutCount;
    TQMap<TQString, TQString> m_descriptionMap;
	
	void setToolTip(const TQString& tip);
	void setPixmap(const TQPixmap& pixmap);
};


class KxkbSystemTray : public KSystemTray
{
	Q_OBJECT 
			
	public:
	KxkbSystemTray():
		KSystemTray(NULL)
	{}
	
	void mouseReleaseEvent(TQMouseEvent *ev)
	{
		if (ev->button() == Qt::LeftButton)
			emit toggled();
		KSystemTray::mouseReleaseEvent(ev);
	}

	signals:
 		void menuActivated(int);
		void toggled();
};


#endif