2 * Copyright (c) 2004 Gunnar Schmi Dt <gunnar@schmi-dt.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
21 #include <plasma/kpanelapplet.h>
22 #include <qpushbutton.h>
23 #include <q3ptrlist.h>
27 #include <QMouseEvent>
29 #include <QTimerEvent>
30 #include <QGridLayout>
31 #include <QResizeEvent>
36 #include <X11/XKBlib.h>
43 class StatusIcon
: public QPushButton
{
46 StatusIcon (const QString
&text
, QWidget
*parent
, const char *name
=0);
49 QSize
minimumSizeHint () const;
51 typedef Q3PtrList
<StatusIcon
> IconList
;
53 class TimeoutIcon
: public StatusIcon
{
56 TimeoutIcon (KInstance
*instance
, const QString
&text
,
57 const QString
&featurename
,
58 QWidget
*parent
, const char *name
=0);
62 void setGlyth (const QString
&glyth
);
63 void setImage (const QString
&name
, int timeout
= 0);
65 void drawButton (QPainter
*p
);
80 class KeyIcon
: public StatusIcon
{
83 KeyIcon (int keyId
, KInstance
*instance
,
84 QWidget
*parent
, const char *name
=0);
86 void setState (bool latched
, bool locked
);
87 void drawButton (QPainter
*p
);
91 void stateChangeRequest (KeyIcon
*source
, bool latched
, bool locked
);
94 void resizeEvent(QResizeEvent
*);
110 class MouseIcon
: public StatusIcon
{
113 MouseIcon (KInstance
*instance
, QWidget
*parent
, const char *name
=0);
115 void setState (int state
);
116 void setActiveKey (int activekey
);
117 void drawButton (QPainter
*p
);
118 void updateImages ();
121 void resizeEvent(QResizeEvent
*);
125 QPixmap leftSelected
;
126 QPixmap middleSelected
;
127 QPixmap rightSelected
;
131 QPixmap leftDotSelected
;
132 QPixmap middleDotSelected
;
133 QPixmap rightDotSelected
;
134 int state
, activekey
;
138 class KbStateApplet
: public KPanelApplet
{
142 KbStateApplet(const QString
& configFile
, Plasma::Type t
= Plasma::Normal
, int actions
= 0,
143 QWidget
*parent
= 0, const char *name
= 0);
146 int widthForHeight(int height
) const;
147 int heightForWidth(int width
) const;
150 void mousePressEvent(QMouseEvent
*e
);
151 void timerEvent(QTimerEvent
*);
152 void resizeEvent(QResizeEvent
*);
153 bool x11Event (XEvent
*);
157 void configureAccessX();
158 void configureMouse();
159 void configureKeyboard();
160 void toggleModifier ();
161 void toggleLockkeys ();
163 void toggleAccessX ();
164 void paletteChanged();
166 void toggleFillSpace ();
169 void setIconDim (int size
);
170 void stateChangeRequest (KeyIcon
*source
, bool latched
, bool locked
);
177 int xkb_base_event_type
;
188 unsigned int accessxFeatures
;
193 void buildPopupMenu();
198 int modifierItem
, lockkeysItem
, mouseItem
, accessxItem
;
200 bool showModifiers
, showLockkeys
, showMouse
, showAccessX
;
207 #endif // __kbstate_h__