Diffstat (limited to 'noncore/applets/zkbapplet/zkbwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/zkbapplet/zkbwidget.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/applets/zkbapplet/zkbwidget.cpp b/noncore/applets/zkbapplet/zkbwidget.cpp index 3acff1e..13d554c 100644 --- a/noncore/applets/zkbapplet/zkbwidget.cpp +++ b/noncore/applets/zkbapplet/zkbwidget.cpp | |||
@@ -49,97 +49,97 @@ bool ZkbWidget::loadKeymap() { | |||
49 | setPixmap(disabled); | 49 | setPixmap(disabled); |
50 | return false; | 50 | return false; |
51 | } | 51 | } |
52 | 52 | ||
53 | connect(km, SIGNAL(stateChanged(const QString&)), | 53 | connect(km, SIGNAL(stateChanged(const QString&)), |
54 | this, SLOT(stateChanged(const QString&))); | 54 | this, SLOT(stateChanged(const QString&))); |
55 | 55 | ||
56 | qwsServer->setKeyboardFilter(km); | 56 | qwsServer->setKeyboardFilter(km); |
57 | 57 | ||
58 | Keymap* oldkm = keymap; | 58 | Keymap* oldkm = keymap; |
59 | keymap = km; | 59 | keymap = km; |
60 | 60 | ||
61 | if (oldkm != 0) { | 61 | if (oldkm != 0) { |
62 | delete oldkm; | 62 | delete oldkm; |
63 | } | 63 | } |
64 | 64 | ||
65 | setText(keymap->getCurrentLabel()); | 65 | setText(keymap->getCurrentLabel()); |
66 | 66 | ||
67 | labels->clear(); | 67 | labels->clear(); |
68 | QStringList l = keymap->listLabels(); | 68 | QStringList l = keymap->listLabels(); |
69 | labels->insertItem(disabled, 0, 0); | 69 | labels->insertItem(disabled, 0, 0); |
70 | int n = 1; | 70 | int n = 1; |
71 | w = 0; | 71 | w = 0; |
72 | for(QStringList::Iterator it = l.begin(); it != l.end(); | 72 | for(QStringList::Iterator it = l.begin(); it != l.end(); |
73 | ++it, n++) { | 73 | ++it, n++) { |
74 | 74 | ||
75 | // printf("label: %s\n", (const char*) (*it).utf8()); | 75 | // printf("label: %s\n", (const char*) (*it).utf8()); |
76 | 76 | ||
77 | labels->insertItem(*it, n, n); | 77 | labels->insertItem(*it, n, n); |
78 | int lw = fm.width(*it); | 78 | int lw = fm.width(*it); |
79 | if (lw > w) { | 79 | if (lw > w) { |
80 | w = lw; | 80 | w = lw; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | if (w == 0) { | 84 | if (w == 0) { |
85 | hide(); | 85 | hide(); |
86 | } else { | 86 | } else { |
87 | show(); | 87 | show(); |
88 | } | 88 | } |
89 | return true; | 89 | return true; |
90 | } | 90 | } |
91 | 91 | ||
92 | QSize ZkbWidget::sizeHint() const { | 92 | QSize ZkbWidget::sizeHint() const { |
93 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); | 93 | return QSize(AppLnk::smallIconSize(),AppLnk::smallIconSize()); |
94 | } | 94 | } |
95 | 95 | ||
96 | void ZkbWidget::stateChanged(const QString& s) { | 96 | void ZkbWidget::stateChanged(const QString& s) { |
97 | //qDebug("stateChanged: %s\n", (const char*) s.utf8()); | 97 | //odebug << "stateChanged: " << (const char*) s.utf8() << "\n" << oendl; |
98 | setText(s); | 98 | setText(s); |
99 | } | 99 | } |
100 | 100 | ||
101 | void ZkbWidget::labelChanged(int id) { | 101 | void ZkbWidget::labelChanged(int id) { |
102 | if (id == 0) { | 102 | if (id == 0) { |
103 | keymap->disable(); | 103 | keymap->disable(); |
104 | setPixmap(disabled); | 104 | setPixmap(disabled); |
105 | return; | 105 | return; |
106 | } | 106 | } |
107 | 107 | ||
108 | keymap->enable(); | 108 | keymap->enable(); |
109 | 109 | ||
110 | QStringList l = keymap->listLabels(); | 110 | QStringList l = keymap->listLabels(); |
111 | QString lbl = l[id-1]; | 111 | QString lbl = l[id-1]; |
112 | 112 | ||
113 | //printf("labelChanged: %s\n", (const char*) lbl.utf8()); | 113 | //printf("labelChanged: %s\n", (const char*) lbl.utf8()); |
114 | State* state = keymap->getStateByLabel(lbl); | 114 | State* state = keymap->getStateByLabel(lbl); |
115 | if (state != 0) { | 115 | if (state != 0) { |
116 | keymap->setCurrentState(state); | 116 | keymap->setCurrentState(state); |
117 | setText(lbl); | 117 | setText(lbl); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | 120 | ||
121 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { | 121 | void ZkbWidget::mouseReleaseEvent(QMouseEvent*) { |
122 | QSize sh = labels->sizeHint(); | 122 | QSize sh = labels->sizeHint(); |
123 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); | 123 | QPoint p = mapToGlobal(QPoint((width()-sh.width())/2,-sh.height())); |
124 | labels->exec(p); | 124 | labels->exec(p); |
125 | } | 125 | } |
126 | 126 | ||
127 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { | 127 | void ZkbWidget::signalReceived(const QCString& msg, const QByteArray& data) { |
128 | QDataStream stream(data, IO_ReadOnly); | 128 | QDataStream stream(data, IO_ReadOnly); |
129 | 129 | ||
130 | if (msg == "enable()") { | 130 | if (msg == "enable()") { |
131 | keymap->enable(); | 131 | keymap->enable(); |
132 | } else if (msg == "disable()") { | 132 | } else if (msg == "disable()") { |
133 | keymap->disable(); | 133 | keymap->disable(); |
134 | } else if (msg == "reload()") { | 134 | } else if (msg == "reload()") { |
135 | QCopEnvelope("QPE/System", "busy()"); | 135 | QCopEnvelope("QPE/System", "busy()"); |
136 | QTimer::singleShot(0, this, SLOT(reload())); | 136 | QTimer::singleShot(0, this, SLOT(reload())); |
137 | } else if (msg == "switch(QString)") { | 137 | } else if (msg == "switch(QString)") { |
138 | QString lbl; | 138 | QString lbl; |
139 | stream >> lbl; | 139 | stream >> lbl; |
140 | 140 | ||
141 | if (keymap != 0) { | 141 | if (keymap != 0) { |
142 | State* state = keymap->getStateByLabel(lbl); | 142 | State* state = keymap->getStateByLabel(lbl); |
143 | if (state != 0) { | 143 | if (state != 0) { |
144 | keymap->setCurrentState(state); | 144 | keymap->setCurrentState(state); |
145 | setText(lbl); | 145 | setText(lbl); |