-rw-r--r-- | noncore/applets/zkbapplet/.cvsignore | 6 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbapplet.cpp | 49 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbapplet.h | 23 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbapplet.pro | 6 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbwidget.cpp | 12 | ||||
-rw-r--r-- | noncore/applets/zkbapplet/zkbwidget.h | 1 |
6 files changed, 21 insertions, 76 deletions
diff --git a/noncore/applets/zkbapplet/.cvsignore b/noncore/applets/zkbapplet/.cvsignore new file mode 100644 index 0000000..0f79c04 --- a/dev/null +++ b/noncore/applets/zkbapplet/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | advancedconfigbase.cpp | ||
3 | advancedconfigbase.h | ||
4 | moc_* | ||
5 | .moc | ||
6 | .obj | ||
diff --git a/noncore/applets/zkbapplet/zkbapplet.cpp b/noncore/applets/zkbapplet/zkbapplet.cpp deleted file mode 100644 index 6c71568..0000000 --- a/noncore/applets/zkbapplet/zkbapplet.cpp +++ b/dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <qlabel.h> | ||
3 | #include <qbutton.h> | ||
4 | #include <qwindowsystem_qws.h> | ||
5 | #include "zkbapplet.h" | ||
6 | #include "zkbwidget.h" | ||
7 | |||
8 | |||
9 | ZkbApplet::ZkbApplet() : app(0){ | ||
10 | } | ||
11 | |||
12 | ZkbApplet::~ZkbApplet() | ||
13 | { | ||
14 | if (app) delete app; | ||
15 | } | ||
16 | |||
17 | QWidget* ZkbApplet::applet(QWidget* parent) { | ||
18 | if (app == 0) { | ||
19 | app = new ZkbWidget(parent); | ||
20 | } | ||
21 | |||
22 | return app; | ||
23 | } | ||
24 | |||
25 | int ZkbApplet::position() const { | ||
26 | return 8; | ||
27 | } | ||
28 | |||
29 | QRESULT ZkbApplet::queryInterface(const QUuid& uuid, QUnknownInterface** iface) { | ||
30 | |||
31 | *iface = 0; | ||
32 | if (uuid == IID_QUnknown) { | ||
33 | *iface = this; | ||
34 | } else if (uuid == IID_TaskbarApplet) { | ||
35 | *iface = this; | ||
36 | } else { | ||
37 | return QS_FALSE; | ||
38 | } | ||
39 | |||
40 | if (*iface) { | ||
41 | (*iface)->addRef(); | ||
42 | } | ||
43 | |||
44 | return QS_OK; | ||
45 | } | ||
46 | |||
47 | Q_EXPORT_INTERFACE() { | ||
48 | Q_CREATE_INSTANCE(ZkbApplet) | ||
49 | } | ||
diff --git a/noncore/applets/zkbapplet/zkbapplet.h b/noncore/applets/zkbapplet/zkbapplet.h deleted file mode 100644 index fcf03b5..0000000 --- a/noncore/applets/zkbapplet/zkbapplet.h +++ b/dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | #include "qpe/taskbarappletinterface.h" | ||
2 | |||
3 | #ifndef ZKBAPPLET_H | ||
4 | #define ZKBAPPLET_H | ||
5 | |||
6 | class ZkbWidget; | ||
7 | |||
8 | class ZkbApplet : public TaskbarAppletInterface { | ||
9 | public: | ||
10 | ZkbApplet(); | ||
11 | virtual ~ZkbApplet(); | ||
12 | |||
13 | QRESULT queryInterface(const QUuid&, QUnknownInterface**); | ||
14 | Q_REFCOUNT | ||
15 | |||
16 | virtual QWidget* applet(QWidget*); | ||
17 | virtual int position() const; | ||
18 | |||
19 | protected: | ||
20 | ZkbWidget* app; | ||
21 | }; | ||
22 | |||
23 | #endif | ||
diff --git a/noncore/applets/zkbapplet/zkbapplet.pro b/noncore/applets/zkbapplet/zkbapplet.pro index 22615d0..8cc1b58 100644 --- a/noncore/applets/zkbapplet/zkbapplet.pro +++ b/noncore/applets/zkbapplet/zkbapplet.pro | |||
@@ -1,22 +1,20 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt plugin warn_on release | 2 | CONFIG += qt plugin warn_on release |
3 | HEADERS = zkbapplet.h\ | 3 | HEADERS = zkbwidget.h \ |
4 | zkbwidget.h \ | ||
5 | ../../apps/keyz-cfg/zkbcfg.h \ | 4 | ../../apps/keyz-cfg/zkbcfg.h \ |
6 | ../../apps/keyz-cfg/zkbnames.h \ | 5 | ../../apps/keyz-cfg/zkbnames.h \ |
7 | ../../apps/keyz-cfg/zkbxml.h \ | 6 | ../../apps/keyz-cfg/zkbxml.h \ |
8 | ../../apps/keyz-cfg/zkb.h | 7 | ../../apps/keyz-cfg/zkb.h |
9 | SOURCES = zkbapplet.cpp \ | 8 | SOURCES = zkbwidget.cpp \ |
10 | zkbwidget.cpp \ | ||
11 | ../../apps/keyz-cfg/zkbcfg.cpp \ | 9 | ../../apps/keyz-cfg/zkbcfg.cpp \ |
12 | ../../apps/keyz-cfg/zkbnames.cpp \ | 10 | ../../apps/keyz-cfg/zkbnames.cpp \ |
13 | ../../apps/keyz-cfg/zkbxml.cpp \ | 11 | ../../apps/keyz-cfg/zkbxml.cpp \ |
14 | ../../apps/keyz-cfg/zkb.cpp | 12 | ../../apps/keyz-cfg/zkb.cpp |
15 | TARGET = zkbapplet | 13 | TARGET = zkbapplet |
16 | DESTDIR = $(OPIEDIR)/plugins/applets | 14 | DESTDIR = $(OPIEDIR)/plugins/applets |
17 | INCLUDEPATH += $(OPIEDIR)/include ../../apps/keyz-cfg | 15 | INCLUDEPATH += $(OPIEDIR)/include ../../apps/keyz-cfg |
18 | DEPENDPATH += ../$(OPIEDIR)/include | 16 | DEPENDPATH += ../$(OPIEDIR)/include |
19 | VERSION = 0.6.0 | 17 | VERSION = 0.6.0 |
20 | LIBS += -lqpe | 18 | LIBS += -lqpe |
21 | 19 | ||
22 | include ( $(OPIEDIR)/include.pro ) | 20 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/applets/zkbapplet/zkbwidget.cpp b/noncore/applets/zkbapplet/zkbwidget.cpp index 05a76e7..0b5ab78 100644 --- a/noncore/applets/zkbapplet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/zkbwidget.cpp | |||
@@ -1,150 +1,162 @@ | |||
1 | #include <opie2/otaskbarapplet.h> | ||
1 | #include <qpe/qcopenvelope_qws.h> | 2 | #include <qpe/qcopenvelope_qws.h> |
2 | #include <qpe/applnk.h> | 3 | #include <qpe/applnk.h> |
3 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
4 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
5 | #include <stdio.h> | 6 | #include <stdio.h> |
6 | #include <unistd.h> | 7 | #include <unistd.h> |
7 | #include "zkbwidget.h" | 8 | #include "zkbwidget.h" |
8 | #include "zkbcfg.h" | 9 | #include "zkbcfg.h" |
9 | 10 | ||
10 | ZkbWidget::ZkbWidget(QWidget* parent):QLabel(parent),keymap(0), | 11 | ZkbWidget::ZkbWidget(QWidget* parent):QLabel(parent),keymap(0), |
11 | disabled(Resource::loadPixmap("zkb-disabled")) { | 12 | disabled(Resource::loadPixmap("zkb-disabled")) { |
12 | 13 | ||
13 | labels = new QPopupMenu(); | 14 | labels = new QPopupMenu(); |
14 | connect(labels, SIGNAL(activated(int)), this, | 15 | connect(labels, SIGNAL(activated(int)), this, |
15 | SLOT(labelChanged(int))); | 16 | SLOT(labelChanged(int))); |
16 | 17 | ||
17 | loadKeymap(); | 18 | loadKeymap(); |
18 | 19 | ||
19 | channel = new QCopChannel("QPE/zkb", this); | 20 | channel = new QCopChannel("QPE/zkb", this); |
20 | connect(channel, SIGNAL(received(const QCString&, const QByteArray&)), | 21 | connect(channel, SIGNAL(received(const QCString&, const QByteArray&)), |
21 | this, SLOT(signalReceived(const QCString&, const QByteArray&))); | 22 | this, SLOT(signalReceived(const QCString&, const QByteArray&))); |
22 | setFixedWidth ( AppLnk::smallIconSize() ); | 23 | setFixedWidth ( AppLnk::smallIconSize() ); |
23 | setFixedHeight ( AppLnk::smallIconSize() ); | 24 | setFixedHeight ( AppLnk::smallIconSize() ); |
24 | } | 25 | } |
25 | 26 | ||
26 | ZkbWidget::~ZkbWidget() { | 27 | ZkbWidget::~ZkbWidget() { |
27 | } | 28 | } |
28 | 29 | ||
30 | int ZkbWidget::position() | ||
31 | { | ||
32 | return 8; | ||
33 | } | ||
34 | |||
29 | bool ZkbWidget::loadKeymap() { | 35 | bool ZkbWidget::loadKeymap() { |
30 | ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb"); | 36 | ZkbConfig c(QPEApplication::qpeDir()+"/share/zkb"); |
31 | QFontMetrics fm(font()); | 37 | QFontMetrics fm(font()); |
32 | 38 | ||
33 | if (keymap != 0) { | 39 | if (keymap != 0) { |
34 | delete keymap; | 40 | delete keymap; |
35 | keymap = 0; | 41 | keymap = 0; |
36 | } | 42 | } |
37 | 43 | ||
38 | Keymap* km = new Keymap(); | 44 | Keymap* km = new Keymap(); |
39 | 45 | ||
40 | if (!c.load("zkb.xml", *km, "")) { | 46 | if (!c.load("zkb.xml", *km, "")) { |
41 | delete km; | 47 | delete km; |
42 | setPixmap(disabled); | 48 | setPixmap(disabled); |
43 | return false; | 49 | return false; |
44 | } | 50 | } |
45 | 51 | ||
46 | connect(km, SIGNAL(stateChanged(const QString&)), | 52 | connect(km, SIGNAL(stateChanged(const QString&)), |
47 | this, SLOT(stateChanged(const QString&))); | 53 | this, SLOT(stateChanged(const QString&))); |
48 | 54 | ||
49 | qwsServer->setKeyboardFilter(km); | 55 | qwsServer->setKeyboardFilter(km); |
50 | 56 | ||
51 | Keymap* oldkm = keymap; | 57 | Keymap* oldkm = keymap; |
52 | keymap = km; | 58 | keymap = km; |
53 | 59 | ||
54 | if (oldkm != 0) { | 60 | if (oldkm != 0) { |
55 | delete oldkm; | 61 | delete oldkm; |
56 | } | 62 | } |
57 | 63 | ||
58 | setText(keymap->getCurrentLabel()); | 64 | setText(keymap->getCurrentLabel()); |
59 | 65 | ||
60 | labels->clear(); | 66 | labels->clear(); |
61 | QStringList l = keymap->listLabels(); | 67 | QStringList l = keymap->listLabels(); |
62 | labels->insertItem(disabled, 0, 0); | 68 | labels->insertItem(disabled, 0, 0); |
63 | int n = 1; | 69 | int n = 1; |
64 | w = 0; | 70 | w = 0; |
65 | for(QStringList::Iterator it = l.begin(); it != l.end(); | 71 | for(QStringList::Iterator it = l.begin(); it != l.end(); |
66 | ++it, n++) { | 72 | ++it, n++) { |
67 | 73 | ||
68 | // printf("label: %s\n", (const char*) (*it).utf8()); | 74 | // printf("label: %s\n", (const char*) (*it).utf8()); |
69 | 75 | ||
70 | labels->insertItem(*it, n, n); | 76 | labels->insertItem(*it, n, n); |
71 | int lw = fm.width(*it); | 77 | int lw = fm.width(*it); |
72 | if (lw > w) { | 78 | if (lw > w) { |
73 | w = lw; | 79 | w = lw; |
74 | } | 80 | } |
75 | } | 81 | } |
76 | 82 | ||
77 | if (w == 0) { | 83 | if (w == 0) { |
78 | hide(); | 84 | hide(); |
79 | } else { | 85 | } else { |
80 | show(); | 86 | show(); |
81 | } | 87 | } |
82 | return true; | 88 | return true; |
83 | } | 89 | } |
84 | 90 | ||
85 | QSize ZkbWidget::sizeHint() const { | 91 | QSize ZkbWidget::sizeHint() const { |
86 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); | 92 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); |
87 | } | 93 | } |
88 | 94 | ||
89 | void ZkbWidget::stateChanged(const QString& s) { | 95 | void ZkbWidget::stateChanged(const QString& s) { |
90 | //qDebug("stateChanged: %s\n", (const char*) s.utf8()); | 96 | //qDebug("stateChanged: %s\n", (const char*) s.utf8()); |
91 | setText(s); | 97 | setText(s); |
92 | } | 98 | } |
93 | 99 | ||
94 | void ZkbWidget::labelChanged(int id) { | 100 | void ZkbWidget::labelChanged(int id) { |
95 | if (id == 0) { | 101 | if (id == 0) { |
96 | keymap->disable(); | 102 | keymap->disable(); |
97 | setPixmap(disabled); | 103 | setPixmap(disabled); |
98 | return; | 104 | return; |
99 | } | 105 | } |
100 | 106 | ||
101 | keymap->enable(); | 107 | keymap->enable(); |
102 | 108 | ||
103 | QStringList l = keymap->listLabels(); | 109 | QStringList l = keymap->listLabels(); |
104 | QString lbl = l[id-1]; | 110 | QString lbl = l[id-1]; |
105 | 111 | ||
106 | //printf("labelChanged: %s\n", (const char*) lbl.utf8()); | 112 | //printf("labelChanged: %s\n", (const char*) lbl.utf8()); |
107 | State* state = keymap->getStateByLabel(lbl); | 113 | State* state = keymap->getStateByLabel(lbl); |
108 | if (state != 0) { | 114 | if (state != 0) { |
109 | keymap->setCurrentState(state); | 115 | keymap->setCurrentState(state); |
110 | setText(lbl); | 116 | setText(lbl); |
111 | } | 117 | } |
112 | } | 118 | } |
113 | 119 | ||
114 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { | 120 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { |
115 | QSize sh = labels->sizeHint(); | 121 | QSize sh = labels->sizeHint(); |
116 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); | 122 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); |
117 | labels->exec(p); | 123 | labels->exec(p); |
118 | } | 124 | } |
119 | 125 | ||
120 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { | 126 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { |
121 | QDataStream stream(data, IO_ReadOnly); | 127 | QDataStream stream(data, IO_ReadOnly); |
122 | 128 | ||
123 | if (msg == "enable()") { | 129 | if (msg == "enable()") { |
124 | keymap->enable(); | 130 | keymap->enable(); |
125 | } else if (msg == "disable()") { | 131 | } else if (msg == "disable()") { |
126 | keymap->disable(); | 132 | keymap->disable(); |
127 | } else if (msg == "reload()") { | 133 | } else if (msg == "reload()") { |
128 | QCopEnvelope("QPE/System", "busy()"); | 134 | QCopEnvelope("QPE/System", "busy()"); |
129 | QTimer::singleShot(0, this, SLOT(reload())); | 135 | QTimer::singleShot(0, this, SLOT(reload())); |
130 | } else if (msg == "switch(QString)") { | 136 | } else if (msg == "switch(QString)") { |
131 | QString lbl; | 137 | QString lbl; |
132 | stream >> lbl; | 138 | stream >> lbl; |
133 | 139 | ||
134 | if (keymap != 0) { | 140 | if (keymap != 0) { |
135 | State* state = keymap->getStateByLabel(lbl); | 141 | State* state = keymap->getStateByLabel(lbl); |
136 | if (state != 0) { | 142 | if (state != 0) { |
137 | keymap->setCurrentState(state); | 143 | keymap->setCurrentState(state); |
138 | setText(lbl); | 144 | setText(lbl); |
139 | } | 145 | } |
140 | } | 146 | } |
141 | } else if (msg == "debug(QString)") { | 147 | } else if (msg == "debug(QString)") { |
142 | QString flag; | 148 | QString flag; |
143 | stream >> flag; | 149 | stream >> flag; |
144 | } | 150 | } |
145 | } | 151 | } |
146 | 152 | ||
147 | void ZkbWidget::reload() { | 153 | void ZkbWidget::reload() { |
148 | loadKeymap(); | 154 | loadKeymap(); |
149 | QCopEnvelope("QPE/System", "notBusy()"); | 155 | QCopEnvelope("QPE/System", "notBusy()"); |
150 | } | 156 | } |
157 | |||
158 | Q_EXPORT_INTERFACE() | ||
159 | { | ||
160 | Q_CREATE_INSTANCE( OTaskbarAppletWrapper<ZkbWidget> ); | ||
161 | } | ||
162 | |||
diff --git a/noncore/applets/zkbapplet/zkbwidget.h b/noncore/applets/zkbapplet/zkbwidget.h index a943563..7c67794 100644 --- a/noncore/applets/zkbapplet/zkbwidget.h +++ b/noncore/applets/zkbapplet/zkbwidget.h | |||
@@ -1,38 +1,39 @@ | |||
1 | #ifndef ZKBWIDGET_H | 1 | #ifndef ZKBWIDGET_H |
2 | #define ZKBWIDGET_H | 2 | #define ZKBWIDGET_H |
3 | 3 | ||
4 | #include <qwidget.h> | 4 | #include <qwidget.h> |
5 | #include <qlabel.h> | 5 | #include <qlabel.h> |
6 | #include <qpopupmenu.h> | 6 | #include <qpopupmenu.h> |
7 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
8 | #include <qcopchannel_qws.h> | 8 | #include <qcopchannel_qws.h> |
9 | 9 | ||
10 | #include "zkb.h" | 10 | #include "zkb.h" |
11 | 11 | ||
12 | class ZkbWidget : public QLabel { | 12 | class ZkbWidget : public QLabel { |
13 | Q_OBJECT | 13 | Q_OBJECT |
14 | 14 | ||
15 | public: | 15 | public: |
16 | ZkbWidget(QWidget* parent); | 16 | ZkbWidget(QWidget* parent); |
17 | ~ZkbWidget(); | 17 | ~ZkbWidget(); |
18 | static int position(); | ||
18 | 19 | ||
19 | QSize sizeHint() const; | 20 | QSize sizeHint() const; |
20 | 21 | ||
21 | protected: | 22 | protected: |
22 | QLabel* label; | 23 | QLabel* label; |
23 | Keymap* keymap; | 24 | Keymap* keymap; |
24 | QPopupMenu* labels; | 25 | QPopupMenu* labels; |
25 | QCopChannel* channel; | 26 | QCopChannel* channel; |
26 | int w, h; | 27 | int w, h; |
27 | QPixmap disabled; | 28 | QPixmap disabled; |
28 | 29 | ||
29 | bool loadKeymap(); | 30 | bool loadKeymap(); |
30 | void mouseReleaseEvent(QMouseEvent*); | 31 | void mouseReleaseEvent(QMouseEvent*); |
31 | 32 | ||
32 | protected slots: | 33 | protected slots: |
33 | void stateChanged(const QString&); | 34 | void stateChanged(const QString&); |
34 | void labelChanged(int id); | 35 | void labelChanged(int id); |
35 | void signalReceived(const QCString& msg, const QByteArray& data); | 36 | void signalReceived(const QCString& msg, const QByteArray& data); |
36 | void reload(); | 37 | void reload(); |
37 | }; | 38 | }; |
38 | #endif | 39 | #endif |