32 files changed, 144 insertions, 3435 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 315ea4a..27ba9ff 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -1,371 +1,366 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.C] Pseudo Terminal Device */ | 3 | /* [MyPty.C] Pseudo Terminal Device */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* -------------------------------------------------------------------------- */ | 10 | /* -------------------------------------------------------------------------- */ |
11 | /* */ | 11 | /* */ |
12 | /* Ported Konsole to Qt/Embedded */ | 12 | /* Ported Konsole to Qt/Embedded */ |
13 | /* */ | 13 | /* */ |
14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 14 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
15 | /* */ | 15 | /* */ |
16 | /* -------------------------------------------------------------------------- */ | 16 | /* -------------------------------------------------------------------------- */ |
17 | 17 | ||
18 | /* If you're compiling konsole on non-Linux platforms and find | 18 | /* If you're compiling konsole on non-Linux platforms and find |
19 | problems that you can track down to this file, please have | 19 | problems that you can track down to this file, please have |
20 | a look into ../README.ports, too. | 20 | a look into ../README.ports, too. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | /*! \file | 23 | /*! \file |
24 | */ | 24 | */ |
25 | 25 | ||
26 | /*! \class TEPty | 26 | /*! \class TEPty |
27 | 27 | ||
28 | \brief Ptys provide a pseudo terminal connection to a program. | 28 | \brief Ptys provide a pseudo terminal connection to a program. |
29 | 29 | ||
30 | Although closely related to pipes, these pseudo terminal connections have | 30 | Although closely related to pipes, these pseudo terminal connections have |
31 | some ability, that makes it nessesary to uses them. Most importent, they | 31 | some ability, that makes it nessesary to uses them. Most importent, they |
32 | know about changing screen sizes and UNIX job control. | 32 | know about changing screen sizes and UNIX job control. |
33 | 33 | ||
34 | Within the terminal emulation framework, this class represents the | 34 | Within the terminal emulation framework, this class represents the |
35 | host side of the terminal together with the connecting serial line. | 35 | host side of the terminal together with the connecting serial line. |
36 | 36 | ||
37 | One can create many instances of this class within a program. | 37 | One can create many instances of this class within a program. |
38 | As a side effect of using this class, a signal(2) handler is | 38 | As a side effect of using this class, a signal(2) handler is |
39 | installed on SIGCHLD. | 39 | installed on SIGCHLD. |
40 | 40 | ||
41 | \par FIXME | 41 | \par FIXME |
42 | 42 | ||
43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] | 43 | [NOTE: much of the technical stuff below will be replaced by forkpty.] |
44 | 44 | ||
45 | publish the SIGCHLD signal if not related to an instance. | 45 | publish the SIGCHLD signal if not related to an instance. |
46 | 46 | ||
47 | clearify TEPty::done vs. TEPty::~TEPty semantics. | 47 | clearify TEPty::done vs. TEPty::~TEPty semantics. |
48 | check if pty is restartable via run after done. | 48 | check if pty is restartable via run after done. |
49 | 49 | ||
50 | \par Pseudo terminals | 50 | \par Pseudo terminals |
51 | 51 | ||
52 | Pseudo terminals are a unique feature of UNIX, and always come in form of | 52 | Pseudo terminals are a unique feature of UNIX, and always come in form of |
53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each | 53 | pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each |
54 | other by the operating system. One may think of them as two serial devices | 54 | other by the operating system. One may think of them as two serial devices |
55 | linked by a null-modem cable. Being based on devices the number of | 55 | linked by a null-modem cable. Being based on devices the number of |
56 | simultanous instances of this class is (globally) limited by the number of | 56 | simultanous instances of this class is (globally) limited by the number of |
57 | those device pairs, which is 256. | 57 | those device pairs, which is 256. |
58 | 58 | ||
59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered | 59 | Another technic are UNIX 98 PTY's. These are supported also, and prefered |
60 | over the (obsolete) predecessor. | 60 | over the (obsolete) predecessor. |
61 | 61 | ||
62 | There's a sinister ioctl(2), signal(2) and job control stuff | 62 | There's a sinister ioctl(2), signal(2) and job control stuff |
63 | nessesary to make everything work as it should. | 63 | nessesary to make everything work as it should. |
64 | */ | 64 | */ |
65 | 65 | ||
66 | #include "procctl.h" | 66 | #include "procctl.h" |
67 | #include "MyPty.h" | 67 | #include "MyPty.h" |
68 | 68 | ||
69 | /* OPIE */ | ||
70 | #include <opie2/odebug.h> | ||
71 | using namespace Opie::Core; | ||
72 | |||
73 | /* QT */ | 69 | /* QT */ |
74 | #include <qsocketnotifier.h> | 70 | #include <qsocketnotifier.h> |
75 | #include <qfile.h> | 71 | #include <qfile.h> |
76 | 72 | ||
77 | /* STD */ | 73 | /* STD */ |
78 | #include <stdlib.h> | 74 | #include <stdlib.h> |
79 | #include <stdio.h> | 75 | #include <stdio.h> |
80 | #include <signal.h> | 76 | #include <signal.h> |
81 | #include <fcntl.h> | 77 | #include <fcntl.h> |
82 | #include <unistd.h> | 78 | #include <unistd.h> |
83 | #include <termios.h> | 79 | #include <termios.h> |
84 | #include <sys/types.h> | 80 | #include <sys/types.h> |
85 | #include <sys/ioctl.h> | 81 | #include <sys/ioctl.h> |
86 | #include <sys/wait.h> | 82 | #include <sys/wait.h> |
87 | 83 | ||
88 | 84 | ||
89 | #ifdef HAVE_OPENPTY | 85 | #ifdef HAVE_OPENPTY |
90 | #include <pty.h> | 86 | #include <pty.h> |
91 | #endif | 87 | #endif |
92 | 88 | ||
93 | #undef VERBOSE_DEBUG | 89 | #undef VERBOSE_DEBUG |
94 | 90 | ||
95 | 91 | ||
96 | /* -------------------------------------------------------------------------- */ | 92 | /* -------------------------------------------------------------------------- */ |
97 | 93 | ||
98 | /*! | 94 | /*! |
99 | Informs the client program about the | 95 | Informs the client program about the |
100 | actual size of the window. | 96 | actual size of the window. |
101 | */ | 97 | */ |
102 | 98 | ||
103 | void MyPty::setSize(int lines, int columns) | 99 | void MyPty::setSize(int lines, int columns) |
104 | { | 100 | { |
105 | owarn << "setting size" << oendl; | ||
106 | struct winsize wsize; | 101 | struct winsize wsize; |
107 | wsize.ws_row = (unsigned short)lines; | 102 | wsize.ws_row = (unsigned short)lines; |
108 | wsize.ws_col = (unsigned short)columns; | 103 | wsize.ws_col = (unsigned short)columns; |
109 | if(m_fd < 0) return; | 104 | if(m_fd < 0) return; |
110 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); | 105 | ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); |
111 | } | 106 | } |
112 | 107 | ||
113 | 108 | ||
114 | void MyPty::donePty() | 109 | void MyPty::donePty() |
115 | { | 110 | { |
116 | // This is code from the Qt DumbTerminal example | 111 | // This is code from the Qt DumbTerminal example |
117 | 112 | ||
118 | ::close(m_fd); | 113 | ::close(m_fd); |
119 | 114 | ||
120 | if (m_cpid) { | 115 | if (m_cpid) { |
121 | kill(m_cpid, SIGHUP); | 116 | kill(m_cpid, SIGHUP); |
122 | //waitpid(m_cpid, &status, 0); | 117 | //waitpid(m_cpid, &status, 0); |
123 | delete m_sn_e; | 118 | delete m_sn_e; |
124 | delete m_sn_r; | 119 | delete m_sn_r; |
125 | m_sn_e = 0l; | 120 | m_sn_e = 0l; |
126 | m_sn_r = 0l; | 121 | m_sn_r = 0l; |
127 | } | 122 | } |
128 | 123 | ||
129 | m_cpid = 0; | 124 | m_cpid = 0; |
130 | m_fd = -1; | 125 | m_fd = -1; |
131 | // emit done(status); | 126 | // emit done(status); |
132 | } | 127 | } |
133 | 128 | ||
134 | 129 | ||
135 | const char* MyPty::deviceName() | 130 | const char* MyPty::deviceName() |
136 | { | 131 | { |
137 | return m_ttynam; | 132 | return m_ttynam; |
138 | } | 133 | } |
139 | 134 | ||
140 | 135 | ||
141 | void MyPty::error() | 136 | void MyPty::error() |
142 | { | 137 | { |
143 | // This is code from the Qt DumbTerminal example | 138 | // This is code from the Qt DumbTerminal example |
144 | donePty(); | 139 | donePty(); |
145 | } | 140 | } |
146 | 141 | ||
147 | void MyPty::start() { | 142 | void MyPty::start() { |
148 | QStrList lis; | 143 | QStrList lis; |
149 | int r =run(m_cmd.latin1(), lis, 0, 0); | 144 | int r =run(m_cmd.latin1(), lis, 0, 0); |
150 | r = r; | 145 | r = r; |
151 | } | 146 | } |
152 | /*! | 147 | /*! |
153 | start the client program. | 148 | start the client program. |
154 | */ | 149 | */ |
155 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 150 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
156 | { | 151 | { |
157 | // This is code from the Qt DumbTerminal example | 152 | // This is code from the Qt DumbTerminal example |
158 | m_cpid = fork(); | 153 | m_cpid = fork(); |
159 | 154 | ||
160 | if ( !m_cpid ) { | 155 | if ( !m_cpid ) { |
161 | // child - exec shell on tty | 156 | // child - exec shell on tty |
162 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 157 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
163 | int ttyfd = ::open(m_ttynam, O_RDWR); | 158 | int ttyfd = ::open(m_ttynam, O_RDWR); |
164 | dup2(ttyfd, STDIN_FILENO); | 159 | dup2(ttyfd, STDIN_FILENO); |
165 | dup2(ttyfd, STDOUT_FILENO); | 160 | dup2(ttyfd, STDOUT_FILENO); |
166 | dup2(ttyfd, STDERR_FILENO); | 161 | dup2(ttyfd, STDERR_FILENO); |
167 | // should be done with tty, so close it | 162 | // should be done with tty, so close it |
168 | ::close(ttyfd); | 163 | ::close(ttyfd); |
169 | static struct termios ttmode; | 164 | static struct termios ttmode; |
170 | if ( setsid() < 0 ) | 165 | if ( setsid() < 0 ) |
171 | perror( "failed to set process group" ); | 166 | perror( "failed to set process group" ); |
172 | #if defined (TIOCSCTTY) | 167 | #if defined (TIOCSCTTY) |
173 | // grabbed from APUE by Stevens | 168 | // grabbed from APUE by Stevens |
174 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 169 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
175 | #endif | 170 | #endif |
176 | tcgetattr( STDIN_FILENO, &ttmode ); | 171 | tcgetattr( STDIN_FILENO, &ttmode ); |
177 | ttmode.c_cc[VINTR] = 3; | 172 | ttmode.c_cc[VINTR] = 3; |
178 | ttmode.c_cc[VERASE] = 8; | 173 | ttmode.c_cc[VERASE] = 8; |
179 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 174 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
180 | setenv("TERM",m_term,1); | 175 | setenv("TERM",m_term,1); |
181 | setenv("COLORTERM","0",1); | 176 | setenv("COLORTERM","0",1); |
182 | EnvironmentMap::Iterator it; | 177 | EnvironmentMap::Iterator it; |
183 | for (it = m_env.begin(); it != m_env.end(); it++) { | 178 | for (it = m_env.begin(); it != m_env.end(); it++) { |
184 | setenv(it.key().latin1(), it.data().latin1(), 1); | 179 | setenv(it.key().latin1(), it.data().latin1(), 1); |
185 | } | 180 | } |
186 | if (getuid() == 0) { | 181 | if (getuid() == 0) { |
187 | char msg[] = "WARNING: You are running this shell as root!\n"; | 182 | char msg[] = "WARNING: You are running this shell as root!\n"; |
188 | write(ttyfd, msg, sizeof(msg)); | 183 | write(ttyfd, msg, sizeof(msg)); |
189 | } | 184 | } |
190 | execl(cmd, cmd, 0); | 185 | execl(cmd, cmd, 0); |
191 | 186 | ||
192 | donePty(); | 187 | donePty(); |
193 | exit(-1); | 188 | exit(-1); |
194 | } | 189 | } |
195 | 190 | ||
196 | // parent - continue as a widget | 191 | // parent - continue as a widget |
197 | delete m_sn_r; | 192 | delete m_sn_r; |
198 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 193 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
199 | delete m_sn_e; | 194 | delete m_sn_e; |
200 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 195 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
201 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 196 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
202 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 197 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
203 | 198 | ||
204 | return 0; | 199 | return 0; |
205 | } | 200 | } |
206 | 201 | ||
207 | int MyPty::openPty() | 202 | int MyPty::openPty() |
208 | { | 203 | { |
209 | // This is code from the Qt DumbTerminal example | 204 | // This is code from the Qt DumbTerminal example |
210 | int ptyfd = -1; | 205 | int ptyfd = -1; |
211 | 206 | ||
212 | #ifdef HAVE_OPENPTY | 207 | #ifdef HAVE_OPENPTY |
213 | int ttyfd; | 208 | int ttyfd; |
214 | if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) ) | 209 | if ( openpty(&ptyfd,&ttyfd,m_ttynam,0,0) ) |
215 | ptyfd = -1; | 210 | ptyfd = -1; |
216 | else | 211 | else |
217 | ::close(ttyfd); // we open the ttynam ourselves. | 212 | ::close(ttyfd); // we open the ttynam ourselves. |
218 | #else | 213 | #else |
219 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 214 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
220 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 215 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
221 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 216 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
222 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 217 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
223 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 218 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
224 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 219 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
225 | ::close(ptyfd); | 220 | ::close(ptyfd); |
226 | ptyfd = -1; | 221 | ptyfd = -1; |
227 | } | 222 | } |
228 | } | 223 | } |
229 | } | 224 | } |
230 | } | 225 | } |
231 | #endif | 226 | #endif |
232 | 227 | ||
233 | if ( ptyfd < 0 ) { | 228 | if ( ptyfd < 0 ) { |
234 | //qApp->exit(1); | 229 | //qApp->exit(1); |
235 | return -1; | 230 | return -1; |
236 | } | 231 | } |
237 | 232 | ||
238 | return ptyfd; | 233 | return ptyfd; |
239 | } | 234 | } |
240 | 235 | ||
241 | /*! | 236 | /*! |
242 | Create an instance. | 237 | Create an instance. |
243 | */ | 238 | */ |
244 | MyPty::MyPty(const Profile& prof) : m_cpid(0) | 239 | MyPty::MyPty(const Profile& prof) : m_cpid(0) |
245 | { | 240 | { |
246 | 241 | ||
247 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); | 242 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); |
248 | switch( term ) { | 243 | switch( term ) { |
249 | default: | 244 | default: |
250 | case Profile::VT100: | 245 | case Profile::VT100: |
251 | case Profile::VT102: | 246 | case Profile::VT102: |
252 | m_term = "vt100"; | 247 | m_term = "vt100"; |
253 | break; | 248 | break; |
254 | case Profile::Linux: | 249 | case Profile::Linux: |
255 | m_term = "linux"; | 250 | m_term = "linux"; |
256 | break; | 251 | break; |
257 | case Profile::XTerm: | 252 | case Profile::XTerm: |
258 | m_term = "xterm"; | 253 | m_term = "xterm"; |
259 | break; | 254 | break; |
260 | } | 255 | } |
261 | m_sn_e = 0l; | 256 | m_sn_e = 0l; |
262 | m_sn_r = 0l; | 257 | m_sn_r = 0l; |
263 | m_fd = openPty(); | 258 | m_fd = openPty(); |
264 | ProcCtl* ctl = ProcCtl::self(); | 259 | ProcCtl* ctl = ProcCtl::self(); |
265 | Q_UNUSED(ctl); | 260 | Q_UNUSED(ctl); |
266 | reload(prof); | 261 | reload(prof); |
267 | } | 262 | } |
268 | 263 | ||
269 | /*! | 264 | /*! |
270 | Destructor. | 265 | Destructor. |
271 | Note that the related client program is not killed | 266 | Note that the related client program is not killed |
272 | (yet) when a instance is deleted. | 267 | (yet) when a instance is deleted. |
273 | */ | 268 | */ |
274 | MyPty::~MyPty() | 269 | MyPty::~MyPty() |
275 | { | 270 | { |
276 | donePty(); | 271 | donePty(); |
277 | } | 272 | } |
278 | QString MyPty::identifier()const { | 273 | QString MyPty::identifier()const { |
279 | return QString::fromLatin1("term"); | 274 | return QString::fromLatin1("term"); |
280 | } | 275 | } |
281 | QString MyPty::name()const{ | 276 | QString MyPty::name()const{ |
282 | return identifier(); | 277 | return identifier(); |
283 | } | 278 | } |
284 | bool MyPty::open() { | 279 | bool MyPty::open() { |
285 | if (m_fd < 0) | 280 | if (m_fd < 0) |
286 | m_fd = openPty(); | 281 | m_fd = openPty(); |
287 | 282 | ||
288 | start(); | 283 | start(); |
289 | return true; | 284 | return true; |
290 | } | 285 | } |
291 | void MyPty::close() { | 286 | void MyPty::close() { |
292 | donePty(); | 287 | donePty(); |
293 | m_fd = openPty(); | 288 | m_fd = openPty(); |
294 | } | 289 | } |
295 | void MyPty::reload( const Profile& prof) { | 290 | void MyPty::reload( const Profile& prof) { |
296 | m_env.clear(); | 291 | m_env.clear(); |
297 | m_cmd = prof.readEntry("Command", "/bin/sh"); | 292 | m_cmd = prof.readEntry("Command", "/bin/sh"); |
298 | 293 | ||
299 | /* | 294 | /* |
300 | * Lets check if m_cmd actually | 295 | * Lets check if m_cmd actually |
301 | * exists.... | 296 | * exists.... |
302 | * we try to use bin/bash and if | 297 | * we try to use bin/bash and if |
303 | * this fails we | 298 | * this fails we |
304 | * will fallback to /bin/sh | 299 | * will fallback to /bin/sh |
305 | * which should be there 100% | 300 | * which should be there 100% |
306 | */ | 301 | */ |
307 | if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) | 302 | if ( m_cmd.stripWhiteSpace() == "/bin/bash" && !QFile::exists(QFile::encodeName(m_cmd) ) ) |
308 | m_cmd = "/bin/sh"; | 303 | m_cmd = "/bin/sh"; |
309 | 304 | ||
310 | 305 | ||
311 | int envcount = prof.readNumEntry("EnvVars", 0); | 306 | int envcount = prof.readNumEntry("EnvVars", 0); |
312 | for (int i=0; i<envcount; i++) { | 307 | for (int i=0; i<envcount; i++) { |
313 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | 308 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); |
314 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | 309 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); |
315 | if (!(name.isEmpty() || value.isEmpty())) { | 310 | if (!(name.isEmpty() || value.isEmpty())) { |
316 | m_env.insert(name, value); | 311 | m_env.insert(name, value); |
317 | } | 312 | } |
318 | } | 313 | } |
319 | } | 314 | } |
320 | /*! sends len bytes through the line */ | 315 | /*! sends len bytes through the line */ |
321 | void MyPty::send(const QByteArray& ar) | 316 | void MyPty::send(const QByteArray& ar) |
322 | { | 317 | { |
323 | #ifdef VERBOSE_DEBUG | 318 | #ifdef VERBOSE_DEBUG |
324 | // verbose debug | 319 | // verbose debug |
325 | printf("sending bytes:\n"); | 320 | printf("sending bytes:\n"); |
326 | for (uint i = 0; i < ar.count(); i++) | 321 | for (uint i = 0; i < ar.count(); i++) |
327 | printf("%c", ar[i]); | 322 | printf("%c", ar[i]); |
328 | printf("\n"); | 323 | printf("\n"); |
329 | #endif | 324 | #endif |
330 | 325 | ||
331 | ::write(m_fd, ar.data(), ar.count()); | 326 | ::write(m_fd, ar.data(), ar.count()); |
332 | } | 327 | } |
333 | 328 | ||
334 | /*! indicates that a block of data is received */ | 329 | /*! indicates that a block of data is received */ |
335 | void MyPty::readPty() | 330 | void MyPty::readPty() |
336 | { | 331 | { |
337 | QByteArray buf(4096); | 332 | QByteArray buf(4096); |
338 | 333 | ||
339 | int len = ::read( m_fd, buf.data(), 4096 ); | 334 | int len = ::read( m_fd, buf.data(), 4096 ); |
340 | 335 | ||
341 | if (len == -1 || len == 0) { | 336 | if (len == -1 || len == 0) { |
342 | donePty(); | 337 | donePty(); |
343 | return; | 338 | return; |
344 | } | 339 | } |
345 | 340 | ||
346 | if (len < 0) | 341 | if (len < 0) |
347 | return; | 342 | return; |
348 | 343 | ||
349 | 344 | ||
350 | buf.resize(len); | 345 | buf.resize(len); |
351 | emit received(buf); | 346 | emit received(buf); |
352 | 347 | ||
353 | #ifdef VERBOSE_DEBUG | 348 | #ifdef VERBOSE_DEBUG |
354 | // verbose debug | 349 | // verbose debug |
355 | printf("read bytes:\n"); | 350 | printf("read bytes:\n"); |
356 | for (uint i = 0; i < buf.count(); i++) | 351 | for (uint i = 0; i < buf.count(); i++) |
357 | printf("%c", buf[i]); | 352 | printf("%c", buf[i]); |
358 | printf("\n"); | 353 | printf("\n"); |
359 | #endif | 354 | #endif |
360 | 355 | ||
361 | } | 356 | } |
362 | QBitArray MyPty::supports()const { | 357 | QBitArray MyPty::supports()const { |
363 | QBitArray ar(3); | 358 | QBitArray ar(3); |
364 | //autoconnect | 359 | //autoconnect |
365 | ar[0] = 1; | 360 | ar[0] = 1; |
366 | // | 361 | // |
367 | ar[1] = 0; | 362 | ar[1] = 0; |
368 | ar[2] = 0; | 363 | ar[2] = 0; |
369 | 364 | ||
370 | return ar; | 365 | return ar; |
371 | } | 366 | } |
diff --git a/noncore/apps/opie-console/TEWidget.cpp b/noncore/apps/opie-console/TEWidget.cpp index d168a5e..98c1793 100644 --- a/noncore/apps/opie-console/TEWidget.cpp +++ b/noncore/apps/opie-console/TEWidget.cpp | |||
@@ -648,709 +648,705 @@ void TEWidget::setScrollbarLocation(int loc) | |||
648 | scrollLoc = loc; | 648 | scrollLoc = loc; |
649 | propagateSize(); | 649 | propagateSize(); |
650 | update(); | 650 | update(); |
651 | } | 651 | } |
652 | 652 | ||
653 | /* ------------------------------------------------------------------------- */ | 653 | /* ------------------------------------------------------------------------- */ |
654 | /* */ | 654 | /* */ |
655 | /* Mouse */ | 655 | /* Mouse */ |
656 | /* */ | 656 | /* */ |
657 | /* ------------------------------------------------------------------------- */ | 657 | /* ------------------------------------------------------------------------- */ |
658 | 658 | ||
659 | /*! | 659 | /*! |
660 | Three different operations can be performed using the mouse, and the | 660 | Three different operations can be performed using the mouse, and the |
661 | routines in this section serve all of them: | 661 | routines in this section serve all of them: |
662 | 662 | ||
663 | 1) The press/release events are exposed to the application | 663 | 1) The press/release events are exposed to the application |
664 | 2) Marking (press and move left button) and Pasting (press middle button) | 664 | 2) Marking (press and move left button) and Pasting (press middle button) |
665 | 3) The right mouse button is used from the configuration menu | 665 | 3) The right mouse button is used from the configuration menu |
666 | 666 | ||
667 | NOTE: During the marking process we attempt to keep the cursor within | 667 | NOTE: During the marking process we attempt to keep the cursor within |
668 | the bounds of the text as being displayed by setting the mouse position | 668 | the bounds of the text as being displayed by setting the mouse position |
669 | whenever the mouse has left the text area. | 669 | whenever the mouse has left the text area. |
670 | 670 | ||
671 | Two reasons to do so: | 671 | Two reasons to do so: |
672 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. | 672 | 1) QT does not allow the `grabMouse' to confine-to the TEWidget. |
673 | Thus a `XGrapPointer' would have to be used instead. | 673 | Thus a `XGrapPointer' would have to be used instead. |
674 | 2) Even if so, this would not help too much, since the text area | 674 | 2) Even if so, this would not help too much, since the text area |
675 | of the TEWidget is normally not identical with it's bounds. | 675 | of the TEWidget is normally not identical with it's bounds. |
676 | 676 | ||
677 | The disadvantage of the current handling is, that the mouse can visibly | 677 | The disadvantage of the current handling is, that the mouse can visibly |
678 | leave the bounds of the widget and is then moved back. Because of the | 678 | leave the bounds of the widget and is then moved back. Because of the |
679 | current construction, and the reasons mentioned above, we cannot do better | 679 | current construction, and the reasons mentioned above, we cannot do better |
680 | without changing the overall construction. | 680 | without changing the overall construction. |
681 | */ | 681 | */ |
682 | 682 | ||
683 | /*! | 683 | /*! |
684 | */ | 684 | */ |
685 | 685 | ||
686 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 686 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
687 | { | 687 | { |
688 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 688 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
689 | if ( !contentsRect().contains(ev->pos()) ) return; | 689 | if ( !contentsRect().contains(ev->pos()) ) return; |
690 | QPoint tL = contentsRect().topLeft(); | 690 | QPoint tL = contentsRect().topLeft(); |
691 | int tLx = tL.x(); | 691 | int tLx = tL.x(); |
692 | int tLy = tL.y(); | 692 | int tLy = tL.y(); |
693 | 693 | ||
694 | word_selection_mode = FALSE; | 694 | word_selection_mode = FALSE; |
695 | 695 | ||
696 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 696 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
697 | if ( ev->button() == LeftButton) | 697 | if ( ev->button() == LeftButton) |
698 | { | 698 | { |
699 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 699 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
700 | 700 | ||
701 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 701 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
702 | 702 | ||
703 | if (mouse_marks || (ev->state() & ShiftButton)) | 703 | if (mouse_marks || (ev->state() & ShiftButton)) |
704 | { | 704 | { |
705 | emit clearSelectionSignal(); | 705 | emit clearSelectionSignal(); |
706 | iPntSel = pntSel = pos; | 706 | iPntSel = pntSel = pos; |
707 | actSel = 1; // left mouse button pressed but nothing selected yet. | 707 | actSel = 1; // left mouse button pressed but nothing selected yet. |
708 | grabMouse( /*crossCursor*/ ); // handle with care! | 708 | grabMouse( /*crossCursor*/ ); // handle with care! |
709 | } | 709 | } |
710 | else | 710 | else |
711 | { | 711 | { |
712 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | 712 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button |
713 | } | 713 | } |
714 | } | 714 | } |
715 | if ( ev->button() == MidButton ) | 715 | if ( ev->button() == MidButton ) |
716 | { | 716 | { |
717 | emitSelection(); | 717 | emitSelection(); |
718 | } | 718 | } |
719 | if ( ev->button() == RightButton ) // Configure | 719 | if ( ev->button() == RightButton ) // Configure |
720 | { | 720 | { |
721 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | 721 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | 724 | ||
725 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) | 725 | void TEWidget::mouseMoveEvent(QMouseEvent* ev) |
726 | { | 726 | { |
727 | // for auto-hiding the cursor, we need mouseTracking | 727 | // for auto-hiding the cursor, we need mouseTracking |
728 | if (ev->state() == NoButton ) return; | 728 | if (ev->state() == NoButton ) return; |
729 | 729 | ||
730 | if (actSel == 0) return; | 730 | if (actSel == 0) return; |
731 | 731 | ||
732 | // don't extend selection while pasting | 732 | // don't extend selection while pasting |
733 | if (ev->state() & MidButton) return; | 733 | if (ev->state() & MidButton) return; |
734 | 734 | ||
735 | //if ( !contentsRect().contains(ev->pos()) ) return; | 735 | //if ( !contentsRect().contains(ev->pos()) ) return; |
736 | QPoint tL = contentsRect().topLeft(); | 736 | QPoint tL = contentsRect().topLeft(); |
737 | int tLx = tL.x(); | 737 | int tLx = tL.x(); |
738 | int tLy = tL.y(); | 738 | int tLy = tL.y(); |
739 | int scroll = scrollbar->value(); | 739 | int scroll = scrollbar->value(); |
740 | 740 | ||
741 | // we're in the process of moving the mouse with the left button pressed | 741 | // we're in the process of moving the mouse with the left button pressed |
742 | // the mouse cursor will kept catched within the bounds of the text in | 742 | // the mouse cursor will kept catched within the bounds of the text in |
743 | // this widget. | 743 | // this widget. |
744 | 744 | ||
745 | // Adjust position within text area bounds. See FIXME above. | 745 | // Adjust position within text area bounds. See FIXME above. |
746 | QPoint pos = ev->pos(); | 746 | QPoint pos = ev->pos(); |
747 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | 747 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); |
748 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | 748 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); |
749 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | 749 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); |
750 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | 750 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); |
751 | // check if we produce a mouse move event by this | 751 | // check if we produce a mouse move event by this |
752 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | 752 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); |
753 | 753 | ||
754 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | 754 | if ( pos.y() == tLy+bY+lines*font_h-1 ) |
755 | { | 755 | { |
756 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | 756 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward |
757 | } | 757 | } |
758 | if ( pos.y() == tLy+bY ) | 758 | if ( pos.y() == tLy+bY ) |
759 | { | 759 | { |
760 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | 760 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback |
761 | } | 761 | } |
762 | 762 | ||
763 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | 763 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); |
764 | QPoint ohere; | 764 | QPoint ohere; |
765 | bool swapping = FALSE; | 765 | bool swapping = FALSE; |
766 | 766 | ||
767 | if ( word_selection_mode ) | 767 | if ( word_selection_mode ) |
768 | { | 768 | { |
769 | // Extend to word boundaries | 769 | // Extend to word boundaries |
770 | int i; | 770 | int i; |
771 | int selClass; | 771 | int selClass; |
772 | 772 | ||
773 | bool left_not_right = ( here.y() < iPntSel.y() || | 773 | bool left_not_right = ( here.y() < iPntSel.y() || |
774 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | 774 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); |
775 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | 775 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || |
776 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | 776 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); |
777 | swapping = left_not_right != old_left_not_right; | 777 | swapping = left_not_right != old_left_not_right; |
778 | 778 | ||
779 | // Find left (left_not_right ? from here : from start) | 779 | // Find left (left_not_right ? from here : from start) |
780 | QPoint left = left_not_right ? here : iPntSel; | 780 | QPoint left = left_not_right ? here : iPntSel; |
781 | i = loc(left.x(),left.y()); | 781 | i = loc(left.x(),left.y()); |
782 | selClass = charClass(image[i].c); | 782 | selClass = charClass(image[i].c); |
783 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | 783 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) |
784 | { i--; left.rx()--; } | 784 | { i--; left.rx()--; } |
785 | 785 | ||
786 | // Find left (left_not_right ? from start : from here) | 786 | // Find left (left_not_right ? from start : from here) |
787 | QPoint right = left_not_right ? iPntSel : here; | 787 | QPoint right = left_not_right ? iPntSel : here; |
788 | i = loc(right.x(),right.y()); | 788 | i = loc(right.x(),right.y()); |
789 | selClass = charClass(image[i].c); | 789 | selClass = charClass(image[i].c); |
790 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | 790 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) |
791 | { i++; right.rx()++; } | 791 | { i++; right.rx()++; } |
792 | 792 | ||
793 | // Pick which is start (ohere) and which is extension (here) | 793 | // Pick which is start (ohere) and which is extension (here) |
794 | if ( left_not_right ) | 794 | if ( left_not_right ) |
795 | { | 795 | { |
796 | here = left; ohere = right; | 796 | here = left; ohere = right; |
797 | } | 797 | } |
798 | else | 798 | else |
799 | { | 799 | { |
800 | here = right; ohere = left; | 800 | here = right; ohere = left; |
801 | } | 801 | } |
802 | } | 802 | } |
803 | 803 | ||
804 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | 804 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved |
805 | 805 | ||
806 | if ( word_selection_mode ) { | 806 | if ( word_selection_mode ) { |
807 | if ( actSel < 2 || swapping ) { | 807 | if ( actSel < 2 || swapping ) { |
808 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | 808 | emit beginSelectionSignal( ohere.x(), ohere.y() ); |
809 | } | 809 | } |
810 | } else if ( actSel < 2 ) { | 810 | } else if ( actSel < 2 ) { |
811 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | 811 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); |
812 | } | 812 | } |
813 | 813 | ||
814 | actSel = 2; // within selection | 814 | actSel = 2; // within selection |
815 | pntSel = here; | 815 | pntSel = here; |
816 | emit extendSelectionSignal( here.x(), here.y() ); | 816 | emit extendSelectionSignal( here.x(), here.y() ); |
817 | } | 817 | } |
818 | 818 | ||
819 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 819 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
820 | { | 820 | { |
821 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 821 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
822 | if ( ev->button() == LeftButton) | 822 | if ( ev->button() == LeftButton) |
823 | { | 823 | { |
824 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 824 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
825 | preserve_line_breaks = TRUE; | 825 | preserve_line_breaks = TRUE; |
826 | actSel = 0; | 826 | actSel = 0; |
827 | 827 | ||
828 | //FIXME: emits a release event even if the mouse is | 828 | //FIXME: emits a release event even if the mouse is |
829 | // outside the range. The procedure used in `mouseMoveEvent' | 829 | // outside the range. The procedure used in `mouseMoveEvent' |
830 | // applies here, too. | 830 | // applies here, too. |
831 | 831 | ||
832 | QPoint tL = contentsRect().topLeft(); | 832 | QPoint tL = contentsRect().topLeft(); |
833 | int tLx = tL.x(); | 833 | int tLx = tL.x(); |
834 | int tLy = tL.y(); | 834 | int tLy = tL.y(); |
835 | 835 | ||
836 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 836 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
837 | emit mouseSignal( 3, // release | 837 | emit mouseSignal( 3, // release |
838 | (ev->x()-tLx-blX)/font_w + 1, | 838 | (ev->x()-tLx-blX)/font_w + 1, |
839 | (ev->y()-tLy-bY)/font_h + 1 ); | 839 | (ev->y()-tLy-bY)/font_h + 1 ); |
840 | releaseMouse(); | 840 | releaseMouse(); |
841 | } | 841 | } |
842 | } | 842 | } |
843 | 843 | ||
844 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) | 844 | void TEWidget::mouseDoubleClickEvent(QMouseEvent* ev) |
845 | { | 845 | { |
846 | if ( ev->button() != LeftButton) return; | 846 | if ( ev->button() != LeftButton) return; |
847 | 847 | ||
848 | QPoint tL = contentsRect().topLeft(); | 848 | QPoint tL = contentsRect().topLeft(); |
849 | int tLx = tL.x(); | 849 | int tLx = tL.x(); |
850 | int tLy = tL.y(); | 850 | int tLy = tL.y(); |
851 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 851 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
852 | 852 | ||
853 | // pass on double click as two clicks. | 853 | // pass on double click as two clicks. |
854 | if (!mouse_marks && !(ev->state() & ShiftButton)) | 854 | if (!mouse_marks && !(ev->state() & ShiftButton)) |
855 | { | 855 | { |
856 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 856 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
857 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | 857 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release |
858 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | 858 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button |
859 | return; | 859 | return; |
860 | } | 860 | } |
861 | 861 | ||
862 | 862 | ||
863 | emit clearSelectionSignal(); | 863 | emit clearSelectionSignal(); |
864 | QPoint bgnSel = pos; | 864 | QPoint bgnSel = pos; |
865 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 865 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
866 | int i = loc(bgnSel.x(),bgnSel.y()); | 866 | int i = loc(bgnSel.x(),bgnSel.y()); |
867 | iPntSel = bgnSel; | 867 | iPntSel = bgnSel; |
868 | 868 | ||
869 | word_selection_mode = TRUE; | 869 | word_selection_mode = TRUE; |
870 | 870 | ||
871 | // find word boundaries... | 871 | // find word boundaries... |
872 | int selClass = charClass(image[i].c); | 872 | int selClass = charClass(image[i].c); |
873 | { | 873 | { |
874 | // set the start... | 874 | // set the start... |
875 | int x = bgnSel.x(); | 875 | int x = bgnSel.x(); |
876 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | 876 | while ( x > 0 && charClass(image[i-1].c) == selClass ) |
877 | { i--; x--; } | 877 | { i--; x--; } |
878 | bgnSel.setX(x); | 878 | bgnSel.setX(x); |
879 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | 879 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); |
880 | 880 | ||
881 | // set the end... | 881 | // set the end... |
882 | i = loc( endSel.x(), endSel.y() ); | 882 | i = loc( endSel.x(), endSel.y() ); |
883 | x = endSel.x(); | 883 | x = endSel.x(); |
884 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | 884 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) |
885 | { i++; x++ ; } | 885 | { i++; x++ ; } |
886 | endSel.setX(x); | 886 | endSel.setX(x); |
887 | actSel = 2; // within selection | 887 | actSel = 2; // within selection |
888 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | 888 | emit extendSelectionSignal( endSel.x(), endSel.y() ); |
889 | emit endSelectionSignal(preserve_line_breaks); | 889 | emit endSelectionSignal(preserve_line_breaks); |
890 | preserve_line_breaks = TRUE; | 890 | preserve_line_breaks = TRUE; |
891 | } | 891 | } |
892 | } | 892 | } |
893 | 893 | ||
894 | void TEWidget::focusInEvent( QFocusEvent * ) | 894 | void TEWidget::focusInEvent( QFocusEvent * ) |
895 | { | 895 | { |
896 | 896 | ||
897 | // do nothing, to prevent repainting | 897 | // do nothing, to prevent repainting |
898 | } | 898 | } |
899 | 899 | ||
900 | 900 | ||
901 | void TEWidget::focusOutEvent( QFocusEvent * ) | 901 | void TEWidget::focusOutEvent( QFocusEvent * ) |
902 | { | 902 | { |
903 | // do nothing, to prevent repainting | 903 | // do nothing, to prevent repainting |
904 | } | 904 | } |
905 | 905 | ||
906 | bool TEWidget::focusNextPrevChild( bool next ) | 906 | bool TEWidget::focusNextPrevChild( bool next ) |
907 | { | 907 | { |
908 | if (next) | 908 | if (next) |
909 | return false; // This disables changing the active part in konqueror | 909 | return false; // This disables changing the active part in konqueror |
910 | // when pressing Tab | 910 | // when pressing Tab |
911 | return QFrame::focusNextPrevChild( next ); | 911 | return QFrame::focusNextPrevChild( next ); |
912 | } | 912 | } |
913 | 913 | ||
914 | 914 | ||
915 | int TEWidget::charClass(char ch) const | 915 | int TEWidget::charClass(char ch) const |
916 | { | 916 | { |
917 | // This might seem like overkill, but imagine if ch was a Unicode | 917 | // This might seem like overkill, but imagine if ch was a Unicode |
918 | // character (Qt 2.0 QChar) - it might then be sensible to separate | 918 | // character (Qt 2.0 QChar) - it might then be sensible to separate |
919 | // the different language ranges, etc. | 919 | // the different language ranges, etc. |
920 | 920 | ||
921 | if ( isspace(ch) ) return ' '; | 921 | if ( isspace(ch) ) return ' '; |
922 | 922 | ||
923 | static const char *word_characters = ":@-./_~"; | 923 | static const char *word_characters = ":@-./_~"; |
924 | if ( isalnum(ch) || strchr(word_characters, ch) ) | 924 | if ( isalnum(ch) || strchr(word_characters, ch) ) |
925 | return 'a'; | 925 | return 'a'; |
926 | 926 | ||
927 | // Everything else is weird | 927 | // Everything else is weird |
928 | return 1; | 928 | return 1; |
929 | } | 929 | } |
930 | 930 | ||
931 | void TEWidget::setMouseMarks(bool on) | 931 | void TEWidget::setMouseMarks(bool on) |
932 | { | 932 | { |
933 | mouse_marks = on; | 933 | mouse_marks = on; |
934 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | 934 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); |
935 | } | 935 | } |
936 | 936 | ||
937 | /* ------------------------------------------------------------------------- */ | 937 | /* ------------------------------------------------------------------------- */ |
938 | /* */ | 938 | /* */ |
939 | /* Clipboard */ | 939 | /* Clipboard */ |
940 | /* */ | 940 | /* */ |
941 | /* ------------------------------------------------------------------------- */ | 941 | /* ------------------------------------------------------------------------- */ |
942 | 942 | ||
943 | #undef KeyPress | 943 | #undef KeyPress |
944 | 944 | ||
945 | void TEWidget::emitSelection() | 945 | void TEWidget::emitSelection() |
946 | // Paste Clipboard by simulating keypress events | 946 | // Paste Clipboard by simulating keypress events |
947 | { | 947 | { |
948 | #ifndef QT_NO_CLIPBOARD | 948 | #ifndef QT_NO_CLIPBOARD |
949 | QString text = QApplication::clipboard()->text(); | 949 | QString text = QApplication::clipboard()->text(); |
950 | if ( ! text.isNull() ) | 950 | if ( ! text.isNull() ) |
951 | { | 951 | { |
952 | text.replace(QRegExp("\n"), "\r"); | 952 | text.replace(QRegExp("\n"), "\r"); |
953 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 953 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
954 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 954 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
955 | emit clearSelectionSignal(); | 955 | emit clearSelectionSignal(); |
956 | } | 956 | } |
957 | #endif | 957 | #endif |
958 | } | 958 | } |
959 | 959 | ||
960 | void TEWidget::emitText(QString text) | 960 | void TEWidget::emitText(QString text) |
961 | { | 961 | { |
962 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | 962 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); |
963 | emit keyPressedSignal(&e); // expose as a big fat keypress event | 963 | emit keyPressedSignal(&e); // expose as a big fat keypress event |
964 | } | 964 | } |
965 | 965 | ||
966 | void TEWidget::pasteClipboard( ) | 966 | void TEWidget::pasteClipboard( ) |
967 | { | 967 | { |
968 | emitSelection(); | 968 | emitSelection(); |
969 | } | 969 | } |
970 | 970 | ||
971 | void TEWidget::setSelection(const QString& t) | 971 | void TEWidget::setSelection(const QString& t) |
972 | { | 972 | { |
973 | #ifndef QT_NO_CLIPBOARD | 973 | #ifndef QT_NO_CLIPBOARD |
974 | // Disconnect signal while WE set the clipboard | 974 | // Disconnect signal while WE set the clipboard |
975 | QObject *cb = QApplication::clipboard(); | 975 | QObject *cb = QApplication::clipboard(); |
976 | QObject::disconnect( cb, SIGNAL(dataChanged()), | 976 | QObject::disconnect( cb, SIGNAL(dataChanged()), |
977 | this, SLOT(onClearSelection()) ); | 977 | this, SLOT(onClearSelection()) ); |
978 | 978 | ||
979 | QApplication::clipboard()->setText(t); | 979 | QApplication::clipboard()->setText(t); |
980 | 980 | ||
981 | QObject::connect( cb, SIGNAL(dataChanged()), | 981 | QObject::connect( cb, SIGNAL(dataChanged()), |
982 | this, SLOT(onClearSelection()) ); | 982 | this, SLOT(onClearSelection()) ); |
983 | #endif | 983 | #endif |
984 | } | 984 | } |
985 | 985 | ||
986 | void TEWidget::onClearSelection() | 986 | void TEWidget::onClearSelection() |
987 | { | 987 | { |
988 | emit clearSelectionSignal(); | 988 | emit clearSelectionSignal(); |
989 | } | 989 | } |
990 | 990 | ||
991 | /* ------------------------------------------------------------------------- */ | 991 | /* ------------------------------------------------------------------------- */ |
992 | /* */ | 992 | /* */ |
993 | /* Keyboard */ | 993 | /* Keyboard */ |
994 | /* */ | 994 | /* */ |
995 | /* ------------------------------------------------------------------------- */ | 995 | /* ------------------------------------------------------------------------- */ |
996 | 996 | ||
997 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | 997 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' |
998 | // due to a bug in `QT' or the ignorance of the author to prevent | 998 | // due to a bug in `QT' or the ignorance of the author to prevent |
999 | // repaint events being emitted to the screen whenever one leaves | 999 | // repaint events being emitted to the screen whenever one leaves |
1000 | // or reenters the screen to/from another application. | 1000 | // or reenters the screen to/from another application. |
1001 | // | 1001 | // |
1002 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | 1002 | // Troll says one needs to change focusInEvent() and focusOutEvent(), |
1003 | // which would also let you have an in-focus cursor and an out-focus | 1003 | // which would also let you have an in-focus cursor and an out-focus |
1004 | // cursor like xterm does. | 1004 | // cursor like xterm does. |
1005 | 1005 | ||
1006 | // for the auto-hide cursor feature, I added empty focusInEvent() and | 1006 | // for the auto-hide cursor feature, I added empty focusInEvent() and |
1007 | // focusOutEvent() so that update() isn't called. | 1007 | // focusOutEvent() so that update() isn't called. |
1008 | // For auto-hide, we need to get keypress-events, but we only get them when | 1008 | // For auto-hide, we need to get keypress-events, but we only get them when |
1009 | // we have focus. | 1009 | // we have focus. |
1010 | 1010 | ||
1011 | void TEWidget::doScroll(int lines) | 1011 | void TEWidget::doScroll(int lines) |
1012 | { | 1012 | { |
1013 | scrollbar->setValue(scrollbar->value()+lines); | 1013 | scrollbar->setValue(scrollbar->value()+lines); |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | 1016 | bool TEWidget::eventFilter( QObject *obj, QEvent *e ) |
1017 | { | 1017 | { |
1018 | if ( (e->type() == QEvent::Accel || | 1018 | if ( (e->type() == QEvent::Accel || |
1019 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 1019 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
1020 | static_cast<QKeyEvent *>( e )->ignore(); | 1020 | static_cast<QKeyEvent *>( e )->ignore(); |
1021 | return true; | 1021 | return true; |
1022 | } | 1022 | } |
1023 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 1023 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
1024 | return FALSE; // not us | 1024 | return FALSE; // not us |
1025 | if ( e->type() == QEvent::Wheel) { | 1025 | if ( e->type() == QEvent::Wheel) { |
1026 | QApplication::sendEvent(scrollbar, e); | 1026 | QApplication::sendEvent(scrollbar, e); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | #ifdef FAKE_CTRL_AND_ALT | 1029 | #ifdef FAKE_CTRL_AND_ALT |
1030 | static bool control = FALSE; | 1030 | static bool control = FALSE; |
1031 | static bool alt = FALSE; | 1031 | static bool alt = FALSE; |
1032 | // odebug << " Has a keyboard with no CTRL and ALT keys, but we fake it:" << oendl; | ||
1033 | bool dele=FALSE; | 1032 | bool dele=FALSE; |
1034 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1033 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1035 | QKeyEvent* ke = (QKeyEvent*)e; | 1034 | QKeyEvent* ke = (QKeyEvent*)e; |
1036 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1035 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1037 | switch (ke->key()) { | 1036 | switch (ke->key()) { |
1038 | case Key_F9: // let this be "Control" | 1037 | case Key_F9: // let this be "Control" |
1039 | control = keydown; | 1038 | control = keydown; |
1040 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1039 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1041 | dele=TRUE; | 1040 | dele=TRUE; |
1042 | break; | 1041 | break; |
1043 | case Key_F13: // let this be "Alt" | 1042 | case Key_F13: // let this be "Alt" |
1044 | alt = keydown; | 1043 | alt = keydown; |
1045 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 1044 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
1046 | dele=TRUE; | 1045 | dele=TRUE; |
1047 | break; | 1046 | break; |
1048 | default: | 1047 | default: |
1049 | if ( control ) { | 1048 | if ( control ) { |
1050 | int a = toupper(ke->ascii())-64; | 1049 | int a = toupper(ke->ascii())-64; |
1051 | if ( a >= 0 && a < ' ' ) { | 1050 | if ( a >= 0 && a < ' ' ) { |
1052 | e = new QKeyEvent(e->type(), ke->key(), | 1051 | e = new QKeyEvent(e->type(), ke->key(), |
1053 | a, ke->state()|ControlButton, QChar(a,0)); | 1052 | a, ke->state()|ControlButton, QChar(a,0)); |
1054 | dele=TRUE; | 1053 | dele=TRUE; |
1055 | } | 1054 | } |
1056 | } | 1055 | } |
1057 | if ( alt ) { | 1056 | if ( alt ) { |
1058 | e = new QKeyEvent(e->type(), ke->key(), | 1057 | e = new QKeyEvent(e->type(), ke->key(), |
1059 | ke->ascii(), ke->state()|AltButton, ke->text()); | 1058 | ke->ascii(), ke->state()|AltButton, ke->text()); |
1060 | dele=TRUE; | 1059 | dele=TRUE; |
1061 | } | 1060 | } |
1062 | } | 1061 | } |
1063 | } | 1062 | } |
1064 | #endif | 1063 | #endif |
1065 | 1064 | ||
1066 | if ( e->type() == QEvent::KeyPress ) { | 1065 | if ( e->type() == QEvent::KeyPress ) { |
1067 | QKeyEvent* ke = (QKeyEvent*)e; | 1066 | QKeyEvent* ke = (QKeyEvent*)e; |
1068 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1067 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1069 | // know where the current selection is. | 1068 | // know where the current selection is. |
1070 | 1069 | ||
1071 | // odebug << "key pressed is 0x" << ke->key() << "" << oendl; | ||
1072 | 1070 | ||
1073 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 1071 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
1074 | |||
1075 | // odebug << "key pressed 2 is 0x" << ke->key() << "" << oendl; | ||
1076 | emitText("\\"); // expose | 1072 | emitText("\\"); // expose |
1077 | } else | 1073 | } else |
1078 | emit keyPressedSignal(ke); // expose | 1074 | emit keyPressedSignal(ke); // expose |
1079 | ke->accept(); | 1075 | ke->accept(); |
1080 | #ifdef FAKE_CTRL_AND_ALT | 1076 | #ifdef FAKE_CTRL_AND_ALT |
1081 | if ( dele ) delete e; | 1077 | if ( dele ) delete e; |
1082 | #endif | 1078 | #endif |
1083 | return true; // stop the event | 1079 | return true; // stop the event |
1084 | } | 1080 | } |
1085 | if ( e->type() == QEvent::Enter ) { | 1081 | if ( e->type() == QEvent::Enter ) { |
1086 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1082 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
1087 | this, SLOT(onClearSelection()) ); | 1083 | this, SLOT(onClearSelection()) ); |
1088 | } | 1084 | } |
1089 | if ( e->type() == QEvent::Leave ) { | 1085 | if ( e->type() == QEvent::Leave ) { |
1090 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | 1086 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), |
1091 | this, SLOT(onClearSelection()) ); | 1087 | this, SLOT(onClearSelection()) ); |
1092 | } | 1088 | } |
1093 | return QFrame::eventFilter( obj, e ); | 1089 | return QFrame::eventFilter( obj, e ); |
1094 | } | 1090 | } |
1095 | 1091 | ||
1096 | /* ------------------------------------------------------------------------- */ | 1092 | /* ------------------------------------------------------------------------- */ |
1097 | /* */ | 1093 | /* */ |
1098 | /* Frame */ | 1094 | /* Frame */ |
1099 | /* */ | 1095 | /* */ |
1100 | /* ------------------------------------------------------------------------- */ | 1096 | /* ------------------------------------------------------------------------- */ |
1101 | 1097 | ||
1102 | void TEWidget::frameChanged() | 1098 | void TEWidget::frameChanged() |
1103 | { | 1099 | { |
1104 | propagateSize(); | 1100 | propagateSize(); |
1105 | update(); | 1101 | update(); |
1106 | } | 1102 | } |
1107 | 1103 | ||
1108 | /* ------------------------------------------------------------------------- */ | 1104 | /* ------------------------------------------------------------------------- */ |
1109 | /* */ | 1105 | /* */ |
1110 | /* Sound */ | 1106 | /* Sound */ |
1111 | /* */ | 1107 | /* */ |
1112 | /* ------------------------------------------------------------------------- */ | 1108 | /* ------------------------------------------------------------------------- */ |
1113 | 1109 | ||
1114 | void TEWidget::Bell() | 1110 | void TEWidget::Bell() |
1115 | { | 1111 | { |
1116 | QApplication::beep(); | 1112 | QApplication::beep(); |
1117 | } | 1113 | } |
1118 | 1114 | ||
1119 | /* ------------------------------------------------------------------------- */ | 1115 | /* ------------------------------------------------------------------------- */ |
1120 | /* */ | 1116 | /* */ |
1121 | /* Auxiluary */ | 1117 | /* Auxiluary */ |
1122 | /* */ | 1118 | /* */ |
1123 | /* ------------------------------------------------------------------------- */ | 1119 | /* ------------------------------------------------------------------------- */ |
1124 | 1120 | ||
1125 | void TEWidget::clearImage() | 1121 | void TEWidget::clearImage() |
1126 | // initialize the image | 1122 | // initialize the image |
1127 | // for internal use only | 1123 | // for internal use only |
1128 | { | 1124 | { |
1129 | for (int y = 0; y < lines; y++) | 1125 | for (int y = 0; y < lines; y++) |
1130 | for (int x = 0; x < columns; x++) | 1126 | for (int x = 0; x < columns; x++) |
1131 | { | 1127 | { |
1132 | image[loc(x,y)].c = 0xff; //' '; | 1128 | image[loc(x,y)].c = 0xff; //' '; |
1133 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | 1129 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; |
1134 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | 1130 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; |
1135 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | 1131 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; |
1136 | } | 1132 | } |
1137 | } | 1133 | } |
1138 | 1134 | ||
1139 | // Create Image /////////////////////////////////////////////////////// | 1135 | // Create Image /////////////////////////////////////////////////////// |
1140 | 1136 | ||
1141 | void TEWidget::calcGeometry() | 1137 | void TEWidget::calcGeometry() |
1142 | { | 1138 | { |
1143 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | 1139 | //FIXME: set rimX == rimY == 0 when running in full screen mode. |
1144 | 1140 | ||
1145 | int showhscrollbar = 1; | 1141 | int showhscrollbar = 1; |
1146 | int hwidth = 0; | 1142 | int hwidth = 0; |
1147 | int dcolumns; | 1143 | int dcolumns; |
1148 | 1144 | ||
1149 | if(vcolumns == 0) showhscrollbar = 0; | 1145 | if(vcolumns == 0) showhscrollbar = 0; |
1150 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1146 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1151 | 1147 | ||
1152 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1148 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1153 | contentsRect().height() - hwidth); | 1149 | contentsRect().height() - hwidth); |
1154 | 1150 | ||
1155 | if(!showhscrollbar) cornerButton()->move(0, 0); | 1151 | if(!showhscrollbar) cornerButton()->move(0, 0); |
1156 | else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); | 1152 | else cornerButton()->move(contentsRect().width() - hwidth, contentsRect().height() - hwidth); |
1157 | 1153 | ||
1158 | 1154 | ||
1159 | switch(scrollLoc) | 1155 | switch(scrollLoc) |
1160 | { | 1156 | { |
1161 | case SCRNONE : | 1157 | case SCRNONE : |
1162 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | 1158 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; |
1163 | dcolumns = columns; | 1159 | dcolumns = columns; |
1164 | if(vcolumns) columns = vcolumns; | 1160 | if(vcolumns) columns = vcolumns; |
1165 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | 1161 | blX = (contentsRect().width() - (columns*font_w) ) / 2; |
1166 | if(showhscrollbar) | 1162 | if(showhscrollbar) |
1167 | blX = -hposition * font_w; | 1163 | blX = -hposition * font_w; |
1168 | brX = blX; | 1164 | brX = blX; |
1169 | scrollbar->hide(); | 1165 | scrollbar->hide(); |
1170 | break; | 1166 | break; |
1171 | case SCRLEFT : | 1167 | case SCRLEFT : |
1172 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1168 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1173 | dcolumns = columns; | 1169 | dcolumns = columns; |
1174 | if(vcolumns) columns = vcolumns; | 1170 | if(vcolumns) columns = vcolumns; |
1175 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1171 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1176 | if(showhscrollbar) | 1172 | if(showhscrollbar) |
1177 | brX = -hposition * font_w; | 1173 | brX = -hposition * font_w; |
1178 | blX = brX + scrollbar->width(); | 1174 | blX = brX + scrollbar->width(); |
1179 | scrollbar->move(contentsRect().topLeft()); | 1175 | scrollbar->move(contentsRect().topLeft()); |
1180 | scrollbar->show(); | 1176 | scrollbar->show(); |
1181 | break; | 1177 | break; |
1182 | case SCRRIGHT: | 1178 | case SCRRIGHT: |
1183 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | 1179 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; |
1184 | dcolumns = columns; | 1180 | dcolumns = columns; |
1185 | if(vcolumns) columns = vcolumns; | 1181 | if(vcolumns) columns = vcolumns; |
1186 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | 1182 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; |
1187 | if(showhscrollbar) | 1183 | if(showhscrollbar) |
1188 | blX = -hposition * font_w; | 1184 | blX = -hposition * font_w; |
1189 | brX = blX; | 1185 | brX = blX; |
1190 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | 1186 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); |
1191 | scrollbar->show(); | 1187 | scrollbar->show(); |
1192 | break; | 1188 | break; |
1193 | } | 1189 | } |
1194 | //FIXME: support 'rounding' styles | 1190 | //FIXME: support 'rounding' styles |
1195 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | 1191 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; |
1196 | bY = (contentsRect().height() - (lines *font_h)) / 2; | 1192 | bY = (contentsRect().height() - (lines *font_h)) / 2; |
1197 | 1193 | ||
1198 | if(showhscrollbar == 1) | 1194 | if(showhscrollbar == 1) |
1199 | { | 1195 | { |
1200 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); | 1196 | hscrollbar->resize(contentsRect().width() - hwidth, hwidth); |
1201 | hscrollbar->setRange(0, vcolumns - dcolumns); | 1197 | hscrollbar->setRange(0, vcolumns - dcolumns); |
1202 | 1198 | ||
1203 | QPoint p = contentsRect().bottomLeft(); | 1199 | QPoint p = contentsRect().bottomLeft(); |
1204 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); | 1200 | hscrollbar->move(QPoint(p.x(), p.y() - hwidth)); |
1205 | hscrollbar->show(); | 1201 | hscrollbar->show(); |
1206 | } | 1202 | } |
1207 | else hscrollbar->hide(); | 1203 | else hscrollbar->hide(); |
1208 | 1204 | ||
1209 | if(showhscrollbar == 1) | 1205 | if(showhscrollbar == 1) |
1210 | { | 1206 | { |
1211 | lines = lines - (hwidth / font_h) - 1; | 1207 | lines = lines - (hwidth / font_h) - 1; |
1212 | if(lines < 1) lines = 1; | 1208 | if(lines < 1) lines = 1; |
1213 | } | 1209 | } |
1214 | } | 1210 | } |
1215 | 1211 | ||
1216 | void TEWidget::makeImage() | 1212 | void TEWidget::makeImage() |
1217 | //FIXME: rename 'calcGeometry? | 1213 | //FIXME: rename 'calcGeometry? |
1218 | { | 1214 | { |
1219 | calcGeometry(); | 1215 | calcGeometry(); |
1220 | image = (ca*) malloc(lines*columns*sizeof(ca)); | 1216 | image = (ca*) malloc(lines*columns*sizeof(ca)); |
1221 | clearImage(); | 1217 | clearImage(); |
1222 | } | 1218 | } |
1223 | 1219 | ||
1224 | // calculate the needed size | 1220 | // calculate the needed size |
1225 | QSize TEWidget::calcSize(int cols, int lins) const | 1221 | QSize TEWidget::calcSize(int cols, int lins) const |
1226 | { | 1222 | { |
1227 | int frw = width() - contentsRect().width(); | 1223 | int frw = width() - contentsRect().width(); |
1228 | int frh = height() - contentsRect().height(); | 1224 | int frh = height() - contentsRect().height(); |
1229 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | 1225 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); |
1230 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | 1226 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); |
1231 | } | 1227 | } |
1232 | 1228 | ||
1233 | QSize TEWidget::sizeHint() const | 1229 | QSize TEWidget::sizeHint() const |
1234 | { | 1230 | { |
1235 | return size(); | 1231 | return size(); |
1236 | } | 1232 | } |
1237 | 1233 | ||
1238 | void TEWidget::styleChange(QStyle &) | 1234 | void TEWidget::styleChange(QStyle &) |
1239 | { | 1235 | { |
1240 | propagateSize(); | 1236 | propagateSize(); |
1241 | } | 1237 | } |
1242 | 1238 | ||
1243 | #ifdef QT_NO_DRAGANDDROP_FOO | 1239 | #ifdef QT_NO_DRAGANDDROP_FOO |
1244 | 1240 | ||
1245 | /* --------------------------------------------------------------------- */ | 1241 | /* --------------------------------------------------------------------- */ |
1246 | /* */ | 1242 | /* */ |
1247 | /* Drag & Drop */ | 1243 | /* Drag & Drop */ |
1248 | /* */ | 1244 | /* */ |
1249 | /* --------------------------------------------------------------------- */ | 1245 | /* --------------------------------------------------------------------- */ |
1250 | 1246 | ||
1251 | 1247 | ||
1252 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) | 1248 | void TEWidget::dragEnterEvent(QDragEnterEvent* e) |
1253 | { | 1249 | { |
1254 | e->accept(QTextDrag::canDecode(e) || | 1250 | e->accept(QTextDrag::canDecode(e) || |
1255 | QUriDrag::canDecode(e)); | 1251 | QUriDrag::canDecode(e)); |
1256 | } | 1252 | } |
1257 | 1253 | ||
1258 | void TEWidget::dropEvent(QDropEvent* event) | 1254 | void TEWidget::dropEvent(QDropEvent* event) |
1259 | { | 1255 | { |
1260 | // The current behaviour when url(s) are dropped is | 1256 | // The current behaviour when url(s) are dropped is |
1261 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | 1257 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd |
1262 | // * in all other cases, just paste | 1258 | // * in all other cases, just paste |
1263 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | 1259 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) |
1264 | QStrList strlist; | 1260 | QStrList strlist; |
1265 | int file_count = 0; | 1261 | int file_count = 0; |
1266 | dropText = ""; | 1262 | dropText = ""; |
1267 | bool bPopup = true; | 1263 | bool bPopup = true; |
1268 | 1264 | ||
1269 | if(QUriDrag::decode(event, strlist)) { | 1265 | if(QUriDrag::decode(event, strlist)) { |
1270 | if (strlist.count()) { | 1266 | if (strlist.count()) { |
1271 | for(const char* p = strlist.first(); p; p = strlist.next()) { | 1267 | for(const char* p = strlist.first(); p; p = strlist.next()) { |
1272 | if(file_count++ > 0) { | 1268 | if(file_count++ > 0) { |
1273 | dropText += " "; | 1269 | dropText += " "; |
1274 | bPopup = false; // more than one file, don't popup | 1270 | bPopup = false; // more than one file, don't popup |
1275 | } | 1271 | } |
1276 | 1272 | ||
1277 | /* | 1273 | /* |
1278 | KURL url(p); | 1274 | KURL url(p); |
1279 | if (url.isLocalFile()) { | 1275 | if (url.isLocalFile()) { |
1280 | dropText += url.path(); // local URL : remove protocol | 1276 | dropText += url.path(); // local URL : remove protocol |
1281 | } | 1277 | } |
1282 | else { | 1278 | else { |
1283 | dropText += url.prettyURL(); | 1279 | dropText += url.prettyURL(); |
1284 | bPopup = false; // a non-local file, don't popup | 1280 | bPopup = false; // a non-local file, don't popup |
1285 | } | 1281 | } |
1286 | */ | 1282 | */ |
1287 | 1283 | ||
1288 | } | 1284 | } |
1289 | 1285 | ||
1290 | if (bPopup) | 1286 | if (bPopup) |
1291 | // m_drop->popup(pos() + event->pos()); | 1287 | // m_drop->popup(pos() + event->pos()); |
1292 | m_drop->popup(mapToGlobal(event->pos())); | 1288 | m_drop->popup(mapToGlobal(event->pos())); |
1293 | else | 1289 | else |
1294 | { | 1290 | { |
1295 | if (currentSession) { | 1291 | if (currentSession) { |
1296 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1292 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1297 | } | 1293 | } |
1298 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1294 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1299 | } | 1295 | } |
1300 | } | 1296 | } |
1301 | } | 1297 | } |
1302 | else if(QTextDrag::decode(event, dropText)) { | 1298 | else if(QTextDrag::decode(event, dropText)) { |
1303 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | 1299 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; |
1304 | if (currentSession) { | 1300 | if (currentSession) { |
1305 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1301 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1306 | } | 1302 | } |
1307 | // Paste it | 1303 | // Paste it |
1308 | } | 1304 | } |
1309 | } | 1305 | } |
1310 | #endif | 1306 | #endif |
1311 | 1307 | ||
1312 | 1308 | ||
1313 | void TEWidget::drop_menu_activated(int) | 1309 | void TEWidget::drop_menu_activated(int) |
1314 | { | 1310 | { |
1315 | #ifdef QT_NO_DRAGANDDROP_FOO | 1311 | #ifdef QT_NO_DRAGANDDROP_FOO |
1316 | switch (item) | 1312 | switch (item) |
1317 | { | 1313 | { |
1318 | case 0: // paste | 1314 | case 0: // paste |
1319 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1315 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1320 | // KWM::activate((Window)this->winId()); | 1316 | // KWM::activate((Window)this->winId()); |
1321 | break; | 1317 | break; |
1322 | case 1: // cd ... | 1318 | case 1: // cd ... |
1323 | currentSession->getEmulation()->sendString("cd "); | 1319 | currentSession->getEmulation()->sendString("cd "); |
1324 | struct stat statbuf; | 1320 | struct stat statbuf; |
1325 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | 1321 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) |
1326 | { | 1322 | { |
1327 | if ( !S_ISDIR(statbuf.st_mode) ) | 1323 | if ( !S_ISDIR(statbuf.st_mode) ) |
1328 | { | 1324 | { |
1329 | /* | 1325 | /* |
1330 | KURL url; | 1326 | KURL url; |
1331 | url.setPath( dropText ); | 1327 | url.setPath( dropText ); |
1332 | dropText = url.directory( true, false ); // remove filename | 1328 | dropText = url.directory( true, false ); // remove filename |
1333 | */ | 1329 | */ |
1334 | } | 1330 | } |
1335 | } | 1331 | } |
1336 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | 1332 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces |
1337 | currentSession->getEmulation()->sendString(dropText.local8Bit()); | 1333 | currentSession->getEmulation()->sendString(dropText.local8Bit()); |
1338 | currentSession->getEmulation()->sendString("\n"); | 1334 | currentSession->getEmulation()->sendString("\n"); |
1339 | // KWM::activate((Window)this->winId()); | 1335 | // KWM::activate((Window)this->winId()); |
1340 | break; | 1336 | break; |
1341 | } | 1337 | } |
1342 | #endif | 1338 | #endif |
1343 | } | 1339 | } |
1344 | 1340 | ||
1345 | QPushButton* TEWidget::cornerButton() { | 1341 | QPushButton* TEWidget::cornerButton() { |
1346 | return m_cornerButton; | 1342 | return m_cornerButton; |
1347 | } | 1343 | } |
1348 | 1344 | ||
1349 | void TEWidget::setWrapAt(int columns) | 1345 | void TEWidget::setWrapAt(int columns) |
1350 | { | 1346 | { |
1351 | vcolumns = columns; | 1347 | vcolumns = columns; |
1352 | propagateSize(); | 1348 | propagateSize(); |
1353 | update(); | 1349 | update(); |
1354 | } | 1350 | } |
1355 | 1351 | ||
1356 | 1352 | ||
diff --git a/noncore/apps/opie-console/TEmulation.cpp b/noncore/apps/opie-console/TEmulation.cpp index 6ff73af..72cce75 100644 --- a/noncore/apps/opie-console/TEmulation.cpp +++ b/noncore/apps/opie-console/TEmulation.cpp | |||
@@ -1,369 +1,364 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEmulation.cpp] Terminal Emulation Decoder */ | 3 | /* [TEmulation.cpp] Terminal Emulation Decoder */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \class TEmulation | 19 | /*! \class TEmulation |
20 | 20 | ||
21 | \brief Mediator between TEWidget and TEScreen. | 21 | \brief Mediator between TEWidget and TEScreen. |
22 | 22 | ||
23 | This class is responsible to scan the escapes sequences of the terminal | 23 | This class is responsible to scan the escapes sequences of the terminal |
24 | emulation and to map it to their corresponding semantic complements. | 24 | emulation and to map it to their corresponding semantic complements. |
25 | Thus this module knows mainly about decoding escapes sequences and | 25 | Thus this module knows mainly about decoding escapes sequences and |
26 | is a stateless device w.r.t. the semantics. | 26 | is a stateless device w.r.t. the semantics. |
27 | 27 | ||
28 | It is also responsible to refresh the TEWidget by certain rules. | 28 | It is also responsible to refresh the TEWidget by certain rules. |
29 | 29 | ||
30 | \sa TEWidget \sa TEScreen | 30 | \sa TEWidget \sa TEScreen |
31 | 31 | ||
32 | \par A note on refreshing | 32 | \par A note on refreshing |
33 | 33 | ||
34 | Although the modifications to the current screen image could immediately | 34 | Although the modifications to the current screen image could immediately |
35 | be propagated via `TEWidget' to the graphical surface, we have chosen | 35 | be propagated via `TEWidget' to the graphical surface, we have chosen |
36 | another way here. | 36 | another way here. |
37 | 37 | ||
38 | The reason for doing so is twofold. | 38 | The reason for doing so is twofold. |
39 | 39 | ||
40 | First, experiments show that directly displaying the operation results | 40 | First, experiments show that directly displaying the operation results |
41 | in slowing down the overall performance of emulations. Displaying | 41 | in slowing down the overall performance of emulations. Displaying |
42 | individual characters using X11 creates a lot of overhead. | 42 | individual characters using X11 creates a lot of overhead. |
43 | 43 | ||
44 | Second, by using the following refreshing method, the screen operations | 44 | Second, by using the following refreshing method, the screen operations |
45 | can be completely separated from the displaying. This greatly simplifies | 45 | can be completely separated from the displaying. This greatly simplifies |
46 | the programmer's task of coding and maintaining the screen operations, | 46 | the programmer's task of coding and maintaining the screen operations, |
47 | since one need not worry about differential modifications on the | 47 | since one need not worry about differential modifications on the |
48 | display affecting the operation of concern. | 48 | display affecting the operation of concern. |
49 | 49 | ||
50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. | 50 | We use a refreshing algorithm here that has been adoped from rxvt/kvt. |
51 | 51 | ||
52 | By this, refreshing is driven by a timer, which is (re)started whenever | 52 | By this, refreshing is driven by a timer, which is (re)started whenever |
53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. | 53 | a new bunch of data to be interpreted by the emulation arives at `onRcvBlock'. |
54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger | 54 | As soon as no more data arrive for `BULK_TIMEOUT' milliseconds, we trigger |
55 | refresh. This rule suits both bulk display operation as done by curses as | 55 | refresh. This rule suits both bulk display operation as done by curses as |
56 | well as individual characters typed. | 56 | well as individual characters typed. |
57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). | 57 | (BULK_TIMEOUT < 1000 / max characters received from keyboard per second). |
58 | 58 | ||
59 | Additionally, we trigger refreshing by newlines comming in to make visual | 59 | Additionally, we trigger refreshing by newlines comming in to make visual |
60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby | 60 | snapshots of lists as produced by `cat', `ls' and likely programs, thereby |
61 | producing the illusion of a permanent and immediate display operation. | 61 | producing the illusion of a permanent and immediate display operation. |
62 | 62 | ||
63 | As a sort of catch-all needed for cases where none of the above | 63 | As a sort of catch-all needed for cases where none of the above |
64 | conditions catch, the screen refresh is also triggered by a count | 64 | conditions catch, the screen refresh is also triggered by a count |
65 | of incoming bulks (`bulk_incnt'). | 65 | of incoming bulks (`bulk_incnt'). |
66 | */ | 66 | */ |
67 | 67 | ||
68 | /* FIXME | 68 | /* FIXME |
69 | - evtl. the bulk operations could be made more transparent. | 69 | - evtl. the bulk operations could be made more transparent. |
70 | */ | 70 | */ |
71 | 71 | ||
72 | #include "TEmulation.h" | 72 | #include "TEmulation.h" |
73 | 73 | ||
74 | /* OPIE */ | ||
75 | #include <opie2/odebug.h> | ||
76 | using namespace Opie::Core; | ||
77 | |||
78 | /* STD */ | 74 | /* STD */ |
79 | #include <stdio.h> | 75 | #include <stdio.h> |
80 | #include <stdlib.h> | 76 | #include <stdlib.h> |
81 | #include <unistd.h> | 77 | #include <unistd.h> |
82 | 78 | ||
83 | 79 | ||
84 | /* ------------------------------------------------------------------------- */ | 80 | /* ------------------------------------------------------------------------- */ |
85 | /* */ | 81 | /* */ |
86 | /* TEmulation */ | 82 | /* TEmulation */ |
87 | /* */ | 83 | /* */ |
88 | /* ------------------------------------------------------------------------- */ | 84 | /* ------------------------------------------------------------------------- */ |
89 | 85 | ||
90 | #define CNTL(c) ((c)-'@') | 86 | #define CNTL(c) ((c)-'@') |
91 | 87 | ||
92 | /*! | 88 | /*! |
93 | */ | 89 | */ |
94 | 90 | ||
95 | TEmulation::TEmulation(TEWidget* gui) | 91 | TEmulation::TEmulation(TEWidget* gui) |
96 | : decoder((QTextDecoder*)NULL) | 92 | : decoder((QTextDecoder*)NULL) |
97 | { | 93 | { |
98 | this->gui = gui; | 94 | this->gui = gui; |
99 | 95 | ||
100 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); | 96 | screen[0] = new TEScreen(gui->Lines(),gui->Columns()); |
101 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); | 97 | screen[1] = new TEScreen(gui->Lines(),gui->Columns()); |
102 | scr = screen[0]; | 98 | scr = screen[0]; |
103 | 99 | ||
104 | bulk_nlcnt = 0; // reset bulk newline counter | 100 | bulk_nlcnt = 0; // reset bulk newline counter |
105 | bulk_incnt = 0; // reset bulk counter | 101 | bulk_incnt = 0; // reset bulk counter |
106 | connected = FALSE; | 102 | connected = FALSE; |
107 | 103 | ||
108 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); | 104 | QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) ); |
109 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), | 105 | QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)), |
110 | this,SLOT(onImageSizeChange(int,int))); | 106 | this,SLOT(onImageSizeChange(int,int))); |
111 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), | 107 | QObject::connect(gui,SIGNAL(changedHistoryCursor(int)), |
112 | this,SLOT(onHistoryCursorChange(int))); | 108 | this,SLOT(onHistoryCursorChange(int))); |
113 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), | 109 | QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)), |
114 | this,SLOT(onKeyPress(QKeyEvent*))); | 110 | this,SLOT(onKeyPress(QKeyEvent*))); |
115 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), | 111 | QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)), |
116 | this,SLOT(onSelectionBegin(const int,const int)) ); | 112 | this,SLOT(onSelectionBegin(const int,const int)) ); |
117 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), | 113 | QObject::connect(gui,SIGNAL(extendSelectionSignal(const int,const int)), |
118 | this,SLOT(onSelectionExtend(const int,const int)) ); | 114 | this,SLOT(onSelectionExtend(const int,const int)) ); |
119 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), | 115 | QObject::connect(gui,SIGNAL(endSelectionSignal(const BOOL)), |
120 | this,SLOT(setSelection(const BOOL)) ); | 116 | this,SLOT(setSelection(const BOOL)) ); |
121 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), | 117 | QObject::connect(gui,SIGNAL(clearSelectionSignal()), |
122 | this,SLOT(clearSelection()) ); | 118 | this,SLOT(clearSelection()) ); |
123 | } | 119 | } |
124 | 120 | ||
125 | /*! | 121 | /*! |
126 | */ | 122 | */ |
127 | 123 | ||
128 | TEmulation::~TEmulation() | 124 | TEmulation::~TEmulation() |
129 | { | 125 | { |
130 | delete screen[0]; | 126 | delete screen[0]; |
131 | delete screen[1]; | 127 | delete screen[1]; |
132 | bulk_timer.stop(); | 128 | bulk_timer.stop(); |
133 | } | 129 | } |
134 | 130 | ||
135 | /*! change between primary and alternate screen | 131 | /*! change between primary and alternate screen |
136 | */ | 132 | */ |
137 | 133 | ||
138 | void TEmulation::setScreen(int n) | 134 | void TEmulation::setScreen(int n) |
139 | { | 135 | { |
140 | scr = screen[n&1]; | 136 | scr = screen[n&1]; |
141 | } | 137 | } |
142 | 138 | ||
143 | void TEmulation::setHistory(bool on) | 139 | void TEmulation::setHistory(bool on) |
144 | { | 140 | { |
145 | screen[0]->setScroll(on); | 141 | screen[0]->setScroll(on); |
146 | if (!connected) return; | 142 | if (!connected) return; |
147 | showBulk(); | 143 | showBulk(); |
148 | } | 144 | } |
149 | 145 | ||
150 | bool TEmulation::history() | 146 | bool TEmulation::history() |
151 | { | 147 | { |
152 | return screen[0]->hasScroll(); | 148 | return screen[0]->hasScroll(); |
153 | } | 149 | } |
154 | 150 | ||
155 | void TEmulation::setCodec(int c) | 151 | void TEmulation::setCodec(int c) |
156 | { | 152 | { |
157 | //FIXME: check whether we have to free codec | 153 | //FIXME: check whether we have to free codec |
158 | codec = c ? QTextCodec::codecForName("utf8") | 154 | codec = c ? QTextCodec::codecForName("utf8") |
159 | : QTextCodec::codecForLocale(); | 155 | : QTextCodec::codecForLocale(); |
160 | if (decoder) delete decoder; | 156 | if (decoder) delete decoder; |
161 | decoder = codec->makeDecoder(); | 157 | decoder = codec->makeDecoder(); |
162 | } | 158 | } |
163 | 159 | ||
164 | void TEmulation::setKeytrans(int no) | 160 | void TEmulation::setKeytrans(int no) |
165 | { | 161 | { |
166 | keytrans = KeyTrans::find(no); | 162 | keytrans = KeyTrans::find(no); |
167 | } | 163 | } |
168 | 164 | ||
169 | void TEmulation::setKeytrans(const char * no) | 165 | void TEmulation::setKeytrans(const char * no) |
170 | { | 166 | { |
171 | keytrans = KeyTrans::find(no); | 167 | keytrans = KeyTrans::find(no); |
172 | } | 168 | } |
173 | 169 | ||
174 | // Interpreting Codes --------------------------------------------------------- | 170 | // Interpreting Codes --------------------------------------------------------- |
175 | 171 | ||
176 | /* | 172 | /* |
177 | This section deals with decoding the incoming character stream. | 173 | This section deals with decoding the incoming character stream. |
178 | Decoding means here, that the stream is first seperated into `tokens' | 174 | Decoding means here, that the stream is first seperated into `tokens' |
179 | which are then mapped to a `meaning' provided as operations by the | 175 | which are then mapped to a `meaning' provided as operations by the |
180 | `Screen' class. | 176 | `Screen' class. |
181 | */ | 177 | */ |
182 | 178 | ||
183 | /*! | 179 | /*! |
184 | */ | 180 | */ |
185 | 181 | ||
186 | void TEmulation::onRcvChar(int c) | 182 | void TEmulation::onRcvChar(int c) |
187 | // process application unicode input to terminal | 183 | // process application unicode input to terminal |
188 | // this is a trivial scanner | 184 | // this is a trivial scanner |
189 | { | 185 | { |
190 | c &= 0xff; | 186 | c &= 0xff; |
191 | switch (c) | 187 | switch (c) |
192 | { | 188 | { |
193 | case '\b' : scr->BackSpace(); break; | 189 | case '\b' : scr->BackSpace(); break; |
194 | case '\t' : scr->Tabulate(); break; | 190 | case '\t' : scr->Tabulate(); break; |
195 | case '\n' : scr->NewLine(); break; | 191 | case '\n' : scr->NewLine(); break; |
196 | case '\r' : scr->Return(); break; | 192 | case '\r' : scr->Return(); break; |
197 | case 0x07 : gui->Bell(); break; | 193 | case 0x07 : gui->Bell(); break; |
198 | default : scr->ShowCharacter(c); break; | 194 | default : scr->ShowCharacter(c); break; |
199 | }; | 195 | }; |
200 | } | 196 | } |
201 | 197 | ||
202 | /* ------------------------------------------------------------------------- */ | 198 | /* ------------------------------------------------------------------------- */ |
203 | /* */ | 199 | /* */ |
204 | /* Keyboard Handling */ | 200 | /* Keyboard Handling */ |
205 | /* */ | 201 | /* */ |
206 | /* ------------------------------------------------------------------------- */ | 202 | /* ------------------------------------------------------------------------- */ |
207 | 203 | ||
208 | /*! | 204 | /*! |
209 | */ | 205 | */ |
210 | 206 | ||
211 | void TEmulation::onKeyPress( QKeyEvent* ev ) | 207 | void TEmulation::onKeyPress( QKeyEvent* ev ) |
212 | { | 208 | { |
213 | owarn << "onKeyPress,...." << oendl; | ||
214 | if (!connected) return; // someone else gets the keys | 209 | if (!connected) return; // someone else gets the keys |
215 | if (scr->getHistCursor() != scr->getHistLines()); | 210 | if (scr->getHistCursor() != scr->getHistLines()); |
216 | scr->setHistCursor(scr->getHistLines()); | 211 | scr->setHistCursor(scr->getHistLines()); |
217 | if (!ev->text().isEmpty()) | 212 | if (!ev->text().isEmpty()) |
218 | { // A block of text | 213 | { // A block of text |
219 | // Note that the text is proper unicode. | 214 | // Note that the text is proper unicode. |
220 | // We should do a conversion here, but since this | 215 | // We should do a conversion here, but since this |
221 | // routine will never be used, we simply emit plain ascii. | 216 | // routine will never be used, we simply emit plain ascii. |
222 | emit sndBlock(ev->text().ascii(),ev->text().length()); | 217 | emit sndBlock(ev->text().ascii(),ev->text().length()); |
223 | } | 218 | } |
224 | else if (ev->ascii()>0) | 219 | else if (ev->ascii()>0) |
225 | { unsigned char c[1]; | 220 | { unsigned char c[1]; |
226 | c[0] = ev->ascii(); | 221 | c[0] = ev->ascii(); |
227 | emit sndBlock((char*)c,1); | 222 | emit sndBlock((char*)c,1); |
228 | } | 223 | } |
229 | } | 224 | } |
230 | 225 | ||
231 | // Unblocking, Byte to Unicode translation --------------------------------- -- | 226 | // Unblocking, Byte to Unicode translation --------------------------------- -- |
232 | 227 | ||
233 | /* | 228 | /* |
234 | We are doing code conversion from locale to unicode first. | 229 | We are doing code conversion from locale to unicode first. |
235 | */ | 230 | */ |
236 | 231 | ||
237 | void TEmulation::onRcvBlock(const char *s, int len) | 232 | void TEmulation::onRcvBlock(const char *s, int len) |
238 | { | 233 | { |
239 | bulkStart(); | 234 | bulkStart(); |
240 | bulk_incnt += 1; | 235 | bulk_incnt += 1; |
241 | for (int i = 0; i < len; i++) | 236 | for (int i = 0; i < len; i++) |
242 | { | 237 | { |
243 | QString result = decoder->toUnicode(&s[i],1); | 238 | QString result = decoder->toUnicode(&s[i],1); |
244 | int reslen = result.length(); | 239 | int reslen = result.length(); |
245 | for (int j = 0; j < reslen; j++) | 240 | for (int j = 0; j < reslen; j++) |
246 | onRcvChar(result[j].unicode()); | 241 | onRcvChar(result[j].unicode()); |
247 | if (s[i] == '\n') bulkNewline(); | 242 | if (s[i] == '\n') bulkNewline(); |
248 | } | 243 | } |
249 | bulkEnd(); | 244 | bulkEnd(); |
250 | } | 245 | } |
251 | 246 | ||
252 | // Selection --------------------------------------------------------------- -- | 247 | // Selection --------------------------------------------------------------- -- |
253 | 248 | ||
254 | void TEmulation::onSelectionBegin(const int x, const int y) { | 249 | void TEmulation::onSelectionBegin(const int x, const int y) { |
255 | if (!connected) return; | 250 | if (!connected) return; |
256 | scr->setSelBeginXY(x,y); | 251 | scr->setSelBeginXY(x,y); |
257 | showBulk(); | 252 | showBulk(); |
258 | } | 253 | } |
259 | 254 | ||
260 | void TEmulation::onSelectionExtend(const int x, const int y) { | 255 | void TEmulation::onSelectionExtend(const int x, const int y) { |
261 | if (!connected) return; | 256 | if (!connected) return; |
262 | scr->setSelExtentXY(x,y); | 257 | scr->setSelExtentXY(x,y); |
263 | showBulk(); | 258 | showBulk(); |
264 | } | 259 | } |
265 | 260 | ||
266 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { | 261 | void TEmulation::setSelection(const BOOL preserve_line_breaks) { |
267 | if (!connected) return; | 262 | if (!connected) return; |
268 | QString t = scr->getSelText(preserve_line_breaks); | 263 | QString t = scr->getSelText(preserve_line_breaks); |
269 | if (!t.isNull()) gui->setSelection(t); | 264 | if (!t.isNull()) gui->setSelection(t); |
270 | } | 265 | } |
271 | 266 | ||
272 | void TEmulation::clearSelection() { | 267 | void TEmulation::clearSelection() { |
273 | if (!connected) return; | 268 | if (!connected) return; |
274 | scr->clearSelection(); | 269 | scr->clearSelection(); |
275 | showBulk(); | 270 | showBulk(); |
276 | } | 271 | } |
277 | void TEmulation::streamHistory(QTextStream* stream) { | 272 | void TEmulation::streamHistory(QTextStream* stream) { |
278 | *stream << scr->getHistory(); | 273 | *stream << scr->getHistory(); |
279 | } | 274 | } |
280 | // Refreshing -------------------------------------------------------------- -- | 275 | // Refreshing -------------------------------------------------------------- -- |
281 | 276 | ||
282 | #define BULK_TIMEOUT 20 | 277 | #define BULK_TIMEOUT 20 |
283 | 278 | ||
284 | /*! | 279 | /*! |
285 | called when \n comes in. Evtl. triggers showBulk at endBulk | 280 | called when \n comes in. Evtl. triggers showBulk at endBulk |
286 | */ | 281 | */ |
287 | 282 | ||
288 | void TEmulation::bulkNewline() | 283 | void TEmulation::bulkNewline() |
289 | { | 284 | { |
290 | bulk_nlcnt += 1; | 285 | bulk_nlcnt += 1; |
291 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies | 286 | bulk_incnt = 0; // reset bulk counter since `nl' rule applies |
292 | } | 287 | } |
293 | 288 | ||
294 | /*! | 289 | /*! |
295 | */ | 290 | */ |
296 | 291 | ||
297 | void TEmulation::showBulk() | 292 | void TEmulation::showBulk() |
298 | { | 293 | { |
299 | bulk_nlcnt = 0; // reset bulk newline counter | 294 | bulk_nlcnt = 0; // reset bulk newline counter |
300 | bulk_incnt = 0; // reset bulk counter | 295 | bulk_incnt = 0; // reset bulk counter |
301 | if (connected) | 296 | if (connected) |
302 | { | 297 | { |
303 | ca* image = scr->getCookedImage(); // get the image | 298 | ca* image = scr->getCookedImage(); // get the image |
304 | gui->setImage(image, | 299 | gui->setImage(image, |
305 | scr->getLines(), | 300 | scr->getLines(), |
306 | scr->getColumns()); // actual refresh | 301 | scr->getColumns()); // actual refresh |
307 | free(image); | 302 | free(image); |
308 | //FIXME: check that we do not trigger other draw event here. | 303 | //FIXME: check that we do not trigger other draw event here. |
309 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); | 304 | gui->setScroll(scr->getHistCursor(),scr->getHistLines()); |
310 | } | 305 | } |
311 | } | 306 | } |
312 | 307 | ||
313 | void TEmulation::bulkStart() | 308 | void TEmulation::bulkStart() |
314 | { | 309 | { |
315 | if (bulk_timer.isActive()) bulk_timer.stop(); | 310 | if (bulk_timer.isActive()) bulk_timer.stop(); |
316 | } | 311 | } |
317 | 312 | ||
318 | void TEmulation::bulkEnd() | 313 | void TEmulation::bulkEnd() |
319 | { | 314 | { |
320 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) | 315 | if ( bulk_nlcnt > gui->Lines() || bulk_incnt > 20 ) |
321 | showBulk(); // resets bulk_??cnt to 0, too. | 316 | showBulk(); // resets bulk_??cnt to 0, too. |
322 | else | 317 | else |
323 | bulk_timer.start(BULK_TIMEOUT,TRUE); | 318 | bulk_timer.start(BULK_TIMEOUT,TRUE); |
324 | } | 319 | } |
325 | 320 | ||
326 | void TEmulation::setConnect(bool c) | 321 | void TEmulation::setConnect(bool c) |
327 | { | 322 | { |
328 | connected = c; | 323 | connected = c; |
329 | if ( connected) | 324 | if ( connected) |
330 | { | 325 | { |
331 | onImageSizeChange(gui->Lines(), gui->Columns()); | 326 | onImageSizeChange(gui->Lines(), gui->Columns()); |
332 | showBulk(); | 327 | showBulk(); |
333 | } | 328 | } |
334 | else | 329 | else |
335 | { | 330 | { |
336 | scr->clearSelection(); | 331 | scr->clearSelection(); |
337 | } | 332 | } |
338 | } | 333 | } |
339 | 334 | ||
340 | // --------------------------------------------------------------------------- | 335 | // --------------------------------------------------------------------------- |
341 | 336 | ||
342 | /*! triggered by image size change of the TEWidget `gui'. | 337 | /*! triggered by image size change of the TEWidget `gui'. |
343 | 338 | ||
344 | This event is simply propagated to the attached screens | 339 | This event is simply propagated to the attached screens |
345 | and to the related serial line. | 340 | and to the related serial line. |
346 | */ | 341 | */ |
347 | 342 | ||
348 | void TEmulation::onImageSizeChange(int lines, int columns) | 343 | void TEmulation::onImageSizeChange(int lines, int columns) |
349 | { | 344 | { |
350 | if (!connected) return; | 345 | if (!connected) return; |
351 | screen[0]->resizeImage(lines,columns); | 346 | screen[0]->resizeImage(lines,columns); |
352 | screen[1]->resizeImage(lines,columns); | 347 | screen[1]->resizeImage(lines,columns); |
353 | showBulk(); | 348 | showBulk(); |
354 | emit ImageSizeChanged(lines,columns); // propagate event to serial line | 349 | emit ImageSizeChanged(lines,columns); // propagate event to serial line |
355 | } | 350 | } |
356 | 351 | ||
357 | void TEmulation::onHistoryCursorChange(int cursor) | 352 | void TEmulation::onHistoryCursorChange(int cursor) |
358 | { | 353 | { |
359 | if (!connected) return; | 354 | if (!connected) return; |
360 | scr->setHistCursor(cursor); | 355 | scr->setHistCursor(cursor); |
361 | showBulk(); | 356 | showBulk(); |
362 | } | 357 | } |
363 | 358 | ||
364 | void TEmulation::setColumns(int columns) | 359 | void TEmulation::setColumns(int columns) |
365 | { | 360 | { |
366 | //FIXME: this goes strange ways. | 361 | //FIXME: this goes strange ways. |
367 | // Can we put this straight or explain it at least? | 362 | // Can we put this straight or explain it at least? |
368 | emit changeColumns(columns); | 363 | emit changeColumns(columns); |
369 | } | 364 | } |
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp index c998f96..f958b52 100644 --- a/noncore/apps/opie-console/atconfigdialog.cpp +++ b/noncore/apps/opie-console/atconfigdialog.cpp | |||
@@ -1,218 +1,212 @@ | |||
1 | #include "atconfigdialog.h" | 1 | #include "atconfigdialog.h" |
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 4 | /* QT */ |
9 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
10 | #include <qspinbox.h> | 6 | #include <qspinbox.h> |
11 | #include <qlayout.h> | 7 | #include <qlayout.h> |
12 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
13 | #include <qtabwidget.h> | 9 | #include <qtabwidget.h> |
14 | #include <qlabel.h> | 10 | #include <qlabel.h> |
15 | #include <qscrollview.h> | 11 | #include <qscrollview.h> |
16 | 12 | ||
17 | ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 13 | ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
18 | : QDialog( parent, name, modal, fl ) { | 14 | : QDialog( parent, name, modal, fl ) { |
19 | 15 | ||
20 | 16 | ||
21 | setCaption( tr( "Dialing parameter setup" ) ); | 17 | setCaption( tr( "Dialing parameter setup" ) ); |
22 | 18 | ||
23 | QVBoxLayout *layout = new QVBoxLayout( this ); | 19 | QVBoxLayout *layout = new QVBoxLayout( this ); |
24 | QTabWidget *tabWidget = new QTabWidget( this ); | 20 | QTabWidget *tabWidget = new QTabWidget( this ); |
25 | 21 | ||
26 | tabWidget->addTab( tab0( this ), tr("Settings1") ); | 22 | tabWidget->addTab( tab0( this ), tr("Settings1") ); |
27 | tabWidget->addTab( tab1( this ), tr("Settings2") ); | 23 | tabWidget->addTab( tab1( this ), tr("Settings2") ); |
28 | 24 | ||
29 | layout->addWidget( tabWidget ); | 25 | layout->addWidget( tabWidget ); |
30 | 26 | ||
31 | } | 27 | } |
32 | 28 | ||
33 | QWidget* ATConfigDialog::tab0( QWidget* parent) { | 29 | QWidget* ATConfigDialog::tab0( QWidget* parent) { |
34 | 30 | ||
35 | 31 | ||
36 | QScrollView* sv = new QScrollView( parent ); | 32 | QScrollView* sv = new QScrollView( parent ); |
37 | 33 | ||
38 | QWidget *returnWidget = new QWidget( sv->viewport() ); | 34 | QWidget *returnWidget = new QWidget( sv->viewport() ); |
39 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 35 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
40 | // sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 36 | // sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
41 | // sv->setFrameShape( QFrame::NoFrame ); | 37 | // sv->setFrameShape( QFrame::NoFrame ); |
42 | 38 | ||
43 | 39 | ||
44 | 40 | ||
45 | 41 | ||
46 | QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 ); | 42 | QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 ); |
47 | 43 | ||
48 | QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget ); | 44 | QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget ); |
49 | initStringLine = new QLineEdit( returnWidget ); | 45 | initStringLine = new QLineEdit( returnWidget ); |
50 | layout->addWidget( initStringLabel, 0, 0 ); | 46 | layout->addWidget( initStringLabel, 0, 0 ); |
51 | layout->addWidget( initStringLine, 0, 1 ); | 47 | layout->addWidget( initStringLine, 0, 1 ); |
52 | 48 | ||
53 | QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget ); | 49 | QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget ); |
54 | resetStringLine = new QLineEdit( returnWidget ); | 50 | resetStringLine = new QLineEdit( returnWidget ); |
55 | layout->addWidget( resetStringLabel, 1, 0 ); | 51 | layout->addWidget( resetStringLabel, 1, 0 ); |
56 | layout->addWidget( resetStringLine, 1, 1 ); | 52 | layout->addWidget( resetStringLine, 1, 1 ); |
57 | 53 | ||
58 | QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget ); | 54 | QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget ); |
59 | dialPref1Line = new QLineEdit( returnWidget ); | 55 | dialPref1Line = new QLineEdit( returnWidget ); |
60 | layout->addWidget( dialPref1Label, 2, 0 ); | 56 | layout->addWidget( dialPref1Label, 2, 0 ); |
61 | layout->addWidget( dialPref1Line, 2, 1 ); | 57 | layout->addWidget( dialPref1Line, 2, 1 ); |
62 | 58 | ||
63 | QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget ); | 59 | QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget ); |
64 | dialSuf1Line = new QLineEdit( returnWidget ); | 60 | dialSuf1Line = new QLineEdit( returnWidget ); |
65 | layout->addWidget( dialSuf1Label, 3, 0 ); | 61 | layout->addWidget( dialSuf1Label, 3, 0 ); |
66 | layout->addWidget( dialSuf1Line, 3, 1 ); | 62 | layout->addWidget( dialSuf1Line, 3, 1 ); |
67 | 63 | ||
68 | QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget ); | 64 | QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget ); |
69 | dialPref2Line = new QLineEdit( returnWidget ); | 65 | dialPref2Line = new QLineEdit( returnWidget ); |
70 | layout->addWidget( dialPref2Label, 4, 0 ); | 66 | layout->addWidget( dialPref2Label, 4, 0 ); |
71 | layout->addWidget( dialPref2Line, 4, 1 ); | 67 | layout->addWidget( dialPref2Line, 4, 1 ); |
72 | 68 | ||
73 | QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget ); | 69 | QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget ); |
74 | dialSuf2Line = new QLineEdit( returnWidget ); | 70 | dialSuf2Line = new QLineEdit( returnWidget ); |
75 | layout->addWidget( dialSuf2Label, 5, 0 ); | 71 | layout->addWidget( dialSuf2Label, 5, 0 ); |
76 | layout->addWidget( dialSuf2Line, 5, 1 ); | 72 | layout->addWidget( dialSuf2Line, 5, 1 ); |
77 | 73 | ||
78 | QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget ); | 74 | QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget ); |
79 | dialPref3Line = new QLineEdit( returnWidget ); | 75 | dialPref3Line = new QLineEdit( returnWidget ); |
80 | layout->addWidget( dialPref3Label, 6, 0 ); | 76 | layout->addWidget( dialPref3Label, 6, 0 ); |
81 | layout->addWidget( dialPref3Line, 6, 1 ); | 77 | layout->addWidget( dialPref3Line, 6, 1 ); |
82 | 78 | ||
83 | QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget ); | 79 | QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget ); |
84 | dialSuf3Line = new QLineEdit( returnWidget ); | 80 | dialSuf3Line = new QLineEdit( returnWidget ); |
85 | layout->addWidget( dialSuf3Label, 7, 0 ); | 81 | layout->addWidget( dialSuf3Label, 7, 0 ); |
86 | layout->addWidget( dialSuf3Line, 7, 1 ); | 82 | layout->addWidget( dialSuf3Line, 7, 1 ); |
87 | 83 | ||
88 | QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget ); | 84 | QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget ); |
89 | connectLine = new QLineEdit( returnWidget ); | 85 | connectLine = new QLineEdit( returnWidget ); |
90 | layout->addWidget( connectLabel, 8, 0 ); | 86 | layout->addWidget( connectLabel, 8, 0 ); |
91 | layout->addWidget( connectLine, 8, 1 ); | 87 | layout->addWidget( connectLine, 8, 1 ); |
92 | 88 | ||
93 | QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget ); | 89 | QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget ); |
94 | hangupLine = new QLineEdit( returnWidget ); | 90 | hangupLine = new QLineEdit( returnWidget ); |
95 | layout->addWidget( hangupLabel, 9, 0 ); | 91 | layout->addWidget( hangupLabel, 9, 0 ); |
96 | layout->addWidget( hangupLine, 9, 1 ); | 92 | layout->addWidget( hangupLine, 9, 1 ); |
97 | 93 | ||
98 | sv->addChild( returnWidget ); | 94 | sv->addChild( returnWidget ); |
99 | 95 | ||
100 | return sv; | 96 | return sv; |
101 | 97 | ||
102 | } | 98 | } |
103 | 99 | ||
104 | QWidget* ATConfigDialog::tab1( QWidget* parent ) { | 100 | QWidget* ATConfigDialog::tab1( QWidget* parent ) { |
105 | 101 | ||
106 | 102 | ||
107 | QWidget *returnWidget = new QWidget( parent ); | 103 | QWidget *returnWidget = new QWidget( parent ); |
108 | 104 | ||
109 | QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 ); | 105 | QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 ); |
110 | 106 | ||
111 | QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget ); | 107 | QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget ); |
112 | dialTimeSpin = new QSpinBox( returnWidget ); | 108 | dialTimeSpin = new QSpinBox( returnWidget ); |
113 | layout->addWidget( dialTimeLabel, 0, 0 ); | 109 | layout->addWidget( dialTimeLabel, 0, 0 ); |
114 | layout->addWidget( dialTimeSpin, 0, 1 ); | 110 | layout->addWidget( dialTimeSpin, 0, 1 ); |
115 | 111 | ||
116 | QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget ); | 112 | QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget ); |
117 | delayRedialSpin = new QSpinBox( returnWidget ); | 113 | delayRedialSpin = new QSpinBox( returnWidget ); |
118 | layout->addWidget( delayRedialLabel, 1, 0 ); | 114 | layout->addWidget( delayRedialLabel, 1, 0 ); |
119 | layout->addWidget( delayRedialSpin, 1, 1 ); | 115 | layout->addWidget( delayRedialSpin, 1, 1 ); |
120 | 116 | ||
121 | QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget ); | 117 | QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget ); |
122 | numberTriesSpin = new QSpinBox( returnWidget ); | 118 | numberTriesSpin = new QSpinBox( returnWidget ); |
123 | layout->addWidget( numberTriesLabel, 2, 0 ); | 119 | layout->addWidget( numberTriesLabel, 2, 0 ); |
124 | layout->addWidget( numberTriesSpin, 2, 1 ); | 120 | layout->addWidget( numberTriesSpin, 2, 1 ); |
125 | 121 | ||
126 | QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget ); | 122 | QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget ); |
127 | dtrDropTimeSpin = new QSpinBox( returnWidget ); | 123 | dtrDropTimeSpin = new QSpinBox( returnWidget ); |
128 | layout->addWidget( dtrDropTimeLabel, 3, 0 ); | 124 | layout->addWidget( dtrDropTimeLabel, 3, 0 ); |
129 | layout->addWidget( dtrDropTimeSpin, 3, 1 ); | 125 | layout->addWidget( dtrDropTimeSpin, 3, 1 ); |
130 | 126 | ||
131 | QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget ); | 127 | QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget ); |
132 | bpsDetectBox = new QComboBox( returnWidget ); | 128 | bpsDetectBox = new QComboBox( returnWidget ); |
133 | layout->addWidget( bpsDetectLabel, 4, 0 ); | 129 | layout->addWidget( bpsDetectLabel, 4, 0 ); |
134 | layout->addWidget( bpsDetectBox, 4, 1 ); | 130 | layout->addWidget( bpsDetectBox, 4, 1 ); |
135 | bpsDetectBox->insertItem( tr("No") ); | 131 | bpsDetectBox->insertItem( tr("No") ); |
136 | bpsDetectBox->insertItem( tr("Yes") ); | 132 | bpsDetectBox->insertItem( tr("Yes") ); |
137 | 133 | ||
138 | QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget ); | 134 | QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget ); |
139 | dcdLinesBox = new QComboBox( returnWidget ); | 135 | dcdLinesBox = new QComboBox( returnWidget ); |
140 | layout->addWidget( dcdLinesLabel, 5, 0 ); | 136 | layout->addWidget( dcdLinesLabel, 5, 0 ); |
141 | layout->addWidget( dcdLinesBox, 5, 1 ); | 137 | layout->addWidget( dcdLinesBox, 5, 1 ); |
142 | dcdLinesBox->insertItem( tr("No") ); | 138 | dcdLinesBox->insertItem( tr("No") ); |
143 | dcdLinesBox->insertItem( tr("Yes") ); | 139 | dcdLinesBox->insertItem( tr("Yes") ); |
144 | 140 | ||
145 | QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget ); | 141 | QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget ); |
146 | multiLineUntagBox = new QComboBox( returnWidget ); | 142 | multiLineUntagBox = new QComboBox( returnWidget ); |
147 | layout->addWidget( multiLineUntagLabel, 6, 0 ); | 143 | layout->addWidget( multiLineUntagLabel, 6, 0 ); |
148 | layout->addWidget( multiLineUntagBox, 6, 1 ); | 144 | layout->addWidget( multiLineUntagBox, 6, 1 ); |
149 | multiLineUntagBox->insertItem( tr("No") ); | 145 | multiLineUntagBox->insertItem( tr("No") ); |
150 | multiLineUntagBox->insertItem( tr("Yes") ); | 146 | multiLineUntagBox->insertItem( tr("Yes") ); |
151 | 147 | ||
152 | return returnWidget; | 148 | return returnWidget; |
153 | 149 | ||
154 | } | 150 | } |
155 | 151 | ||
156 | 152 | ||
157 | void ATConfigDialog::readConfig( const Profile& config ) { | 153 | void ATConfigDialog::readConfig( const Profile& config ) { |
158 | owarn << "config in atconfigdialog" << oendl; | ||
159 | |||
160 | initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); | 154 | initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); |
161 | resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); | 155 | resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); |
162 | dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 156 | dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
163 | dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 157 | dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
164 | dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 158 | dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
165 | dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 159 | dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
166 | dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 160 | dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
167 | dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 161 | dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
168 | connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) ); | 162 | connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) ); |
169 | hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); | 163 | hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); |
170 | dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) ); | 164 | dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) ); |
171 | delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) ); | 165 | delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) ); |
172 | numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) ); | 166 | numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) ); |
173 | dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) ); | 167 | dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) ); |
174 | bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) ); | 168 | bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) ); |
175 | dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) ); | 169 | dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) ); |
176 | multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) ); | 170 | multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) ); |
177 | 171 | ||
178 | // Not implemented yet | 172 | // Not implemented yet |
179 | resetStringLine->setEnabled(false); | 173 | resetStringLine->setEnabled(false); |
180 | dialSuf1Line->setEnabled(false); | 174 | dialSuf1Line->setEnabled(false); |
181 | dialPref2Line->setEnabled(false); | 175 | dialPref2Line->setEnabled(false); |
182 | dialSuf2Line->setEnabled(false); | 176 | dialSuf2Line->setEnabled(false); |
183 | dialPref3Line->setEnabled(false); | 177 | dialPref3Line->setEnabled(false); |
184 | dialSuf3Line->setEnabled(false); | 178 | dialSuf3Line->setEnabled(false); |
185 | dialTimeSpin->setEnabled(false); | 179 | dialTimeSpin->setEnabled(false); |
186 | delayRedialSpin->setEnabled(false); | 180 | delayRedialSpin->setEnabled(false); |
187 | numberTriesSpin->setEnabled(false); | 181 | numberTriesSpin->setEnabled(false); |
188 | dtrDropTimeSpin->setEnabled(false); | 182 | dtrDropTimeSpin->setEnabled(false); |
189 | bpsDetectBox->setEnabled(false); | 183 | bpsDetectBox->setEnabled(false); |
190 | dcdLinesBox->setEnabled(false); | 184 | dcdLinesBox->setEnabled(false); |
191 | multiLineUntagBox->setEnabled(false); | 185 | multiLineUntagBox->setEnabled(false); |
192 | } | 186 | } |
193 | 187 | ||
194 | void ATConfigDialog::writeConfig( Profile& config ) { | 188 | void ATConfigDialog::writeConfig( Profile& config ) { |
195 | 189 | ||
196 | config.writeEntry( "InitString", initStringLine->text() ); | 190 | config.writeEntry( "InitString", initStringLine->text() ); |
197 | config.writeEntry( "ResetString", resetStringLine->text() ); | 191 | config.writeEntry( "ResetString", resetStringLine->text() ); |
198 | config.writeEntry( "DialPrefix1", dialPref1Line->text() ); | 192 | config.writeEntry( "DialPrefix1", dialPref1Line->text() ); |
199 | config.writeEntry( "DialSuffix1", dialSuf1Line->text() ); | 193 | config.writeEntry( "DialSuffix1", dialSuf1Line->text() ); |
200 | config.writeEntry( "DialPrefix2", dialPref2Line->text() ); | 194 | config.writeEntry( "DialPrefix2", dialPref2Line->text() ); |
201 | config.writeEntry( "DialSuffix2", dialSuf2Line->text() ); | 195 | config.writeEntry( "DialSuffix2", dialSuf2Line->text() ); |
202 | config.writeEntry( "DialPrefix3", dialPref3Line->text() ); | 196 | config.writeEntry( "DialPrefix3", dialPref3Line->text() ); |
203 | config.writeEntry( "DialSuffix3", dialSuf3Line->text() ); | 197 | config.writeEntry( "DialSuffix3", dialSuf3Line->text() ); |
204 | config.writeEntry( "DefaultConnect", connectLine->text() ); | 198 | config.writeEntry( "DefaultConnect", connectLine->text() ); |
205 | config.writeEntry( "HangupString", hangupLine->text() ); | 199 | config.writeEntry( "HangupString", hangupLine->text() ); |
206 | config.writeEntry( "DialTime", dialTimeSpin->value() ); | 200 | config.writeEntry( "DialTime", dialTimeSpin->value() ); |
207 | config.writeEntry( "DelayRedial", delayRedialSpin->value() ); | 201 | config.writeEntry( "DelayRedial", delayRedialSpin->value() ); |
208 | config.writeEntry( "NumberTries", numberTriesSpin->value() ); | 202 | config.writeEntry( "NumberTries", numberTriesSpin->value() ); |
209 | config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() ); | 203 | config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() ); |
210 | config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() ); | 204 | config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() ); |
211 | config.writeEntry( "DCDLines", dcdLinesBox->currentItem() ); | 205 | config.writeEntry( "DCDLines", dcdLinesBox->currentItem() ); |
212 | config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() ); | 206 | config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() ); |
213 | 207 | ||
214 | } | 208 | } |
215 | 209 | ||
216 | 210 | ||
217 | ATConfigDialog::~ATConfigDialog() { | 211 | ATConfigDialog::~ATConfigDialog() { |
218 | } | 212 | } |
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp index 232e497..f2ed558 100644 --- a/noncore/apps/opie-console/btconfigwidget.cpp +++ b/noncore/apps/opie-console/btconfigwidget.cpp | |||
@@ -1,208 +1,198 @@ | |||
1 | #include "btconfigwidget.h" | ||
2 | #include "iolayerbase.h" | ||
3 | #include "comboboxhelper.h" | ||
4 | |||
1 | #include <qlabel.h> | 5 | #include <qlabel.h> |
2 | #include <qlayout.h> | 6 | #include <qlayout.h> |
3 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
4 | #include <qcombobox.h> | 8 | #include <qcombobox.h> |
5 | #include <qhbox.h> | 9 | #include <qhbox.h> |
6 | #include <qradiobutton.h> | 10 | #include <qradiobutton.h> |
7 | 11 | ||
8 | #include "iolayerbase.h" | ||
9 | #include "btconfigwidget.h" | ||
10 | 12 | ||
11 | namespace { | 13 | |
12 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
13 | uint b = bo->count(); | ||
14 | for (int i = 0; i < bo->count(); i++ ) { | ||
15 | if ( bo->text(i) == str ) { | ||
16 | bo->setCurrentItem( i ); | ||
17 | return; | ||
18 | } | ||
19 | } | ||
20 | bo->insertItem( str ); | ||
21 | bo->setCurrentItem( b ); | ||
22 | } | ||
23 | } | ||
24 | 14 | ||
25 | BTConfigWidget::BTConfigWidget( const QString& name, | 15 | BTConfigWidget::BTConfigWidget( const QString& name, |
26 | QWidget* parent, | 16 | QWidget* parent, |
27 | const char* na ) | 17 | const char* na ) |
28 | : ProfileDialogConnectionWidget( name, parent, na ) { | 18 | : ProfileDialogConnectionWidget( name, parent, na ) { |
29 | 19 | ||
30 | m_lay = new QVBoxLayout( this ); | 20 | m_lay = new QVBoxLayout( this ); |
31 | 21 | ||
32 | m_device = new QLabel( tr( "Device" ), this ); | 22 | m_device = new QLabel( tr( "Device" ), this ); |
33 | QHBox *deviceBox = new QHBox( this ); | 23 | QHBox *deviceBox = new QHBox( this ); |
34 | m_devRadio = new QRadioButton( deviceBox ); | 24 | m_devRadio = new QRadioButton( deviceBox ); |
35 | connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) ); | 25 | connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) ); |
36 | m_deviceCmb = new QComboBox( deviceBox ); | 26 | m_deviceCmb = new QComboBox( deviceBox ); |
37 | m_deviceCmb->setEditable( TRUE ); | 27 | m_deviceCmb->setEditable( TRUE ); |
38 | 28 | ||
39 | QLabel *macLabel = new QLabel( this ); | 29 | QLabel *macLabel = new QLabel( this ); |
40 | macLabel->setText( tr( "Or peer mac address" ) ); | 30 | macLabel->setText( tr( "Or peer mac address" ) ); |
41 | QHBox *macBox = new QHBox( this ); | 31 | QHBox *macBox = new QHBox( this ); |
42 | m_macRadio = new QRadioButton( macBox ); | 32 | m_macRadio = new QRadioButton( macBox ); |
43 | connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) ); | 33 | connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) ); |
44 | m_mac = new QLineEdit( macBox ); | 34 | m_mac = new QLineEdit( macBox ); |
45 | 35 | ||
46 | m_base = new IOLayerBase(this, "base"); | 36 | m_base = new IOLayerBase(this, "base"); |
47 | 37 | ||
48 | m_lay->addWidget( m_device ); | 38 | m_lay->addWidget( m_device ); |
49 | m_lay->addWidget( deviceBox ); | 39 | m_lay->addWidget( deviceBox ); |
50 | m_lay->addWidget( macLabel ); | 40 | m_lay->addWidget( macLabel ); |
51 | m_lay->addWidget( macBox ); | 41 | m_lay->addWidget( macBox ); |
52 | m_lay->addWidget( m_base ); | 42 | m_lay->addWidget( m_base ); |
53 | 43 | ||
54 | m_deviceCmb->insertItem( "/dev/ttyU0" ); | 44 | m_deviceCmb->insertItem( "/dev/ttyU0" ); |
55 | m_deviceCmb->insertItem( "/dev/ttyU1" ); | 45 | m_deviceCmb->insertItem( "/dev/ttyU1" ); |
56 | } | 46 | } |
57 | 47 | ||
58 | BTConfigWidget::~BTConfigWidget() { | 48 | BTConfigWidget::~BTConfigWidget() { |
59 | 49 | ||
60 | } | 50 | } |
61 | void BTConfigWidget::load( const Profile& prof ) { | 51 | void BTConfigWidget::load( const Profile& prof ) { |
62 | int rad_flow = prof.readNumEntry("Flow"); | 52 | int rad_flow = prof.readNumEntry("Flow"); |
63 | int rad_parity = prof.readNumEntry("Parity"); | 53 | int rad_parity = prof.readNumEntry("Parity"); |
64 | int speed = prof.readNumEntry("Speed"); | 54 | int speed = prof.readNumEntry("Speed"); |
65 | QString mac = prof.readEntry("Mac"); | 55 | QString mac = prof.readEntry("Mac"); |
66 | 56 | ||
67 | if (!mac.isEmpty() ) { | 57 | if (!mac.isEmpty() ) { |
68 | m_mac->setText( mac ); | 58 | m_mac->setText( mac ); |
69 | } else { | 59 | } else { |
70 | m_devRadio->setChecked( true ); | 60 | m_devRadio->setChecked( true ); |
71 | } | 61 | } |
72 | 62 | ||
73 | if (rad_flow == 1) { | 63 | if (rad_flow == 1) { |
74 | m_base->setFlow( IOLayerBase::Hardware ); | 64 | m_base->setFlow( IOLayerBase::Hardware ); |
75 | } else if (rad_flow == 2) { | 65 | } else if (rad_flow == 2) { |
76 | m_base->setFlow( IOLayerBase::Software ); | 66 | m_base->setFlow( IOLayerBase::Software ); |
77 | } else if (rad_flow == 0) { | 67 | } else if (rad_flow == 0) { |
78 | m_base->setFlow( IOLayerBase::None ); | 68 | m_base->setFlow( IOLayerBase::None ); |
79 | } | 69 | } |
80 | 70 | ||
81 | if (rad_parity == 1) { | 71 | if (rad_parity == 1) { |
82 | m_base->setParity( IOLayerBase::Even ); | 72 | m_base->setParity( IOLayerBase::Even ); |
83 | } else if ( rad_parity == 2 ) { | 73 | } else if ( rad_parity == 2 ) { |
84 | m_base->setParity( IOLayerBase::Odd ); | 74 | m_base->setParity( IOLayerBase::Odd ); |
85 | } else { | 75 | } else { |
86 | m_base->setParity( IOLayerBase::NonePar ); | 76 | m_base->setParity( IOLayerBase::NonePar ); |
87 | } | 77 | } |
88 | 78 | ||
89 | switch( speed ) { | 79 | switch( speed ) { |
90 | case 115200: | 80 | case 115200: |
91 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 81 | m_base->setSpeed(IOLayerBase::Baud_115200 ); |
92 | break; | 82 | break; |
93 | case 57600: | 83 | case 57600: |
94 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 84 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
95 | break; | 85 | break; |
96 | case 38400: | 86 | case 38400: |
97 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 87 | m_base->setSpeed(IOLayerBase::Baud_38400 ); |
98 | break; | 88 | break; |
99 | case 19200: | 89 | case 19200: |
100 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 90 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
101 | break; | 91 | break; |
102 | case 4800: | 92 | case 4800: |
103 | m_base->setSpeed( IOLayerBase::Baud_4800 ); | 93 | m_base->setSpeed( IOLayerBase::Baud_4800 ); |
104 | break; | 94 | break; |
105 | case 2400: | 95 | case 2400: |
106 | m_base->setSpeed( IOLayerBase::Baud_2400 ); | 96 | m_base->setSpeed( IOLayerBase::Baud_2400 ); |
107 | break; | 97 | break; |
108 | case 1200: | 98 | case 1200: |
109 | m_base->setSpeed( IOLayerBase::Baud_1200 ); | 99 | m_base->setSpeed( IOLayerBase::Baud_1200 ); |
110 | break; | 100 | break; |
111 | case 9600: | 101 | case 9600: |
112 | default: | 102 | default: |
113 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 103 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
114 | break; | 104 | break; |
115 | } | 105 | } |
116 | 106 | ||
117 | if ( prof.readEntry("Device").isEmpty() ) return; | 107 | if ( prof.readEntry("Device").isEmpty() ) return; |
118 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 108 | ComboboxHelper::setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
119 | 109 | ||
120 | } | 110 | } |
121 | /* | 111 | /* |
122 | * save speed, | 112 | * save speed, |
123 | * flow, | 113 | * flow, |
124 | * parity | 114 | * parity |
125 | */ | 115 | */ |
126 | void BTConfigWidget::save( Profile& prof ) { | 116 | void BTConfigWidget::save( Profile& prof ) { |
127 | int flow, parity, speed; | 117 | int flow, parity, speed; |
128 | flow = parity = speed = 0; | 118 | flow = parity = speed = 0; |
129 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 119 | prof.writeEntry("Device", m_deviceCmb->currentText() ); |
130 | 120 | ||
131 | 121 | ||
132 | switch( m_base->flow() ) { | 122 | switch( m_base->flow() ) { |
133 | case IOLayerBase::None: | 123 | case IOLayerBase::None: |
134 | flow = 0; | 124 | flow = 0; |
135 | break; | 125 | break; |
136 | case IOLayerBase::Software: | 126 | case IOLayerBase::Software: |
137 | flow = 2; | 127 | flow = 2; |
138 | break; | 128 | break; |
139 | case IOLayerBase::Hardware: | 129 | case IOLayerBase::Hardware: |
140 | flow = 1; | 130 | flow = 1; |
141 | break; | 131 | break; |
142 | } | 132 | } |
143 | 133 | ||
144 | switch( m_base->parity() ) { | 134 | switch( m_base->parity() ) { |
145 | case IOLayerBase::Odd: | 135 | case IOLayerBase::Odd: |
146 | parity = 2; | 136 | parity = 2; |
147 | break; | 137 | break; |
148 | case IOLayerBase::Even: | 138 | case IOLayerBase::Even: |
149 | parity = 1; | 139 | parity = 1; |
150 | break; | 140 | break; |
151 | case IOLayerBase::NonePar: | 141 | case IOLayerBase::NonePar: |
152 | parity = 0; | 142 | parity = 0; |
153 | break; | 143 | break; |
154 | } | 144 | } |
155 | 145 | ||
156 | switch( m_base->speed() ) { | 146 | switch( m_base->speed() ) { |
157 | case IOLayerBase::Baud_115200: | 147 | case IOLayerBase::Baud_115200: |
158 | speed = 115200; | 148 | speed = 115200; |
159 | break; | 149 | break; |
160 | case IOLayerBase::Baud_57600: | 150 | case IOLayerBase::Baud_57600: |
161 | speed = 57600; | 151 | speed = 57600; |
162 | break; | 152 | break; |
163 | case IOLayerBase::Baud_38400: | 153 | case IOLayerBase::Baud_38400: |
164 | speed = 38400; | 154 | speed = 38400; |
165 | break; | 155 | break; |
166 | case IOLayerBase::Baud_19200: | 156 | case IOLayerBase::Baud_19200: |
167 | speed = 19200; | 157 | speed = 19200; |
168 | break; | 158 | break; |
169 | case IOLayerBase::Baud_4800: | 159 | case IOLayerBase::Baud_4800: |
170 | speed = 4800; | 160 | speed = 4800; |
171 | break; | 161 | break; |
172 | case IOLayerBase::Baud_2400: | 162 | case IOLayerBase::Baud_2400: |
173 | speed = 2400; | 163 | speed = 2400; |
174 | break; | 164 | break; |
175 | case IOLayerBase::Baud_1200: | 165 | case IOLayerBase::Baud_1200: |
176 | speed = 1200; | 166 | speed = 1200; |
177 | break; | 167 | break; |
178 | default: | 168 | default: |
179 | case IOLayerBase::Baud_9600: | 169 | case IOLayerBase::Baud_9600: |
180 | speed = 9600; | 170 | speed = 9600; |
181 | break; | 171 | break; |
182 | } | 172 | } |
183 | 173 | ||
184 | prof.writeEntry("Flow", flow); | 174 | prof.writeEntry("Flow", flow); |
185 | prof.writeEntry("Parity", parity); | 175 | prof.writeEntry("Parity", parity); |
186 | prof.writeEntry("Speed", speed); | 176 | prof.writeEntry("Speed", speed); |
187 | prof.writeEntry("Mac", m_mac->text() ); | 177 | prof.writeEntry("Mac", m_mac->text() ); |
188 | } | 178 | } |
189 | 179 | ||
190 | void BTConfigWidget::slotMacRadio( bool on ) { | 180 | void BTConfigWidget::slotMacRadio( bool on ) { |
191 | if ( on ) { | 181 | if ( on ) { |
192 | m_devRadio->setChecked( false ); | 182 | m_devRadio->setChecked( false ); |
193 | m_deviceCmb->setEnabled( false ); | 183 | m_deviceCmb->setEnabled( false ); |
194 | m_mac->setEnabled( true ); | 184 | m_mac->setEnabled( true ); |
195 | } else { | 185 | } else { |
196 | m_devRadio->setChecked( true ); | 186 | m_devRadio->setChecked( true ); |
197 | } | 187 | } |
198 | } | 188 | } |
199 | 189 | ||
200 | void BTConfigWidget::slotDevRadio( bool on ) { | 190 | void BTConfigWidget::slotDevRadio( bool on ) { |
201 | if ( on ) { | 191 | if ( on ) { |
202 | m_macRadio->setChecked( false ); | 192 | m_macRadio->setChecked( false ); |
203 | m_deviceCmb->setEnabled( true ); | 193 | m_deviceCmb->setEnabled( true ); |
204 | m_mac->setEnabled( false ); | 194 | m_mac->setEnabled( false ); |
205 | } else { | 195 | } else { |
206 | m_macRadio->setChecked( true ); | 196 | m_macRadio->setChecked( true ); |
207 | } | 197 | } |
208 | } | 198 | } |
diff --git a/noncore/apps/opie-console/comboboxhelper.cpp b/noncore/apps/opie-console/comboboxhelper.cpp new file mode 100644 index 0000000..1bfe0a7 --- a/dev/null +++ b/noncore/apps/opie-console/comboboxhelper.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002,2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.BIN. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include "comboboxhelper.h" | ||
30 | |||
31 | #include <qstring.h> | ||
32 | #include <qcombobox.h> | ||
33 | |||
34 | /** | ||
35 | * \brief Set string to be Current String inside the QCombox without duplicating it | ||
36 | * | ||
37 | * This method will make \par str the current QString. If | ||
38 | * the QString is already inside the QComboBox it will be | ||
39 | * set current. If it isn't it will be added. | ||
40 | * | ||
41 | * @param str The QString to be set current | ||
42 | * @param bo The QComboBox to operate on | ||
43 | */ | ||
44 | void ComboboxHelper::setCurrent( const QString& str, QComboBox* bo ) { | ||
45 | const uint b = bo->count(); | ||
46 | for (uint i = 0; i < b; i++ ) { | ||
47 | if ( bo->text(i) == str ) { | ||
48 | bo->setCurrentItem( i ); | ||
49 | return; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | bo->insertItem( str ); | ||
54 | bo->setCurrentItem( b ); | ||
55 | } | ||
diff --git a/noncore/apps/opie-console/comboboxhelper.h b/noncore/apps/opie-console/comboboxhelper.h new file mode 100644 index 0000000..40153bf --- a/dev/null +++ b/noncore/apps/opie-console/comboboxhelper.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002,2004 Holger Hans Peter Freyther <freyther@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This program is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.BIN. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | #ifndef COMBO_BOX_HELPER_H | ||
29 | #define COMBO_BOX_HELPER_H | ||
30 | |||
31 | #include <qstring.h> | ||
32 | |||
33 | |||
34 | class QComboBox; | ||
35 | |||
36 | |||
37 | /** | ||
38 | * \brief ComboboxHelper with a small Helper for Configuring it | ||
39 | * | ||
40 | * ComboboxHelper contains methods for helping managing | ||
41 | * Comboboxes with 'dynamic' data. | ||
42 | * All Methods related to this class are static and operate | ||
43 | * on a QComboBox. | ||
44 | */ | ||
45 | struct ComboboxHelper { | ||
46 | static void setCurrent(const QString&, QComboBox *); | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 7010594..8883b83 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -1,320 +1,308 @@ | |||
1 | #include "dialer.h" | 1 | #include "dialer.h" |
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 4 | /* QT */ |
9 | #include <qlayout.h> | 5 | #include <qlayout.h> |
10 | #include <qprogressbar.h> | 6 | #include <qprogressbar.h> |
11 | #include <qlabel.h> | 7 | #include <qlabel.h> |
12 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
13 | #include <qapp.h> | 9 | #include <qapp.h> |
14 | #include <qtimer.h> | 10 | #include <qtimer.h> |
15 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
16 | 12 | ||
17 | /* STD */ | 13 | /* STD */ |
18 | #include <unistd.h> | 14 | #include <unistd.h> |
19 | #include <string.h> | 15 | #include <string.h> |
20 | #include <fcntl.h> | 16 | #include <fcntl.h> |
21 | #include <errno.h> | 17 | #include <errno.h> |
22 | 18 | ||
23 | // State machine: | When an error occurs, we don't have to | 19 | // State machine: | When an error occurs, we don't have to |
24 | // | reset everything. | 20 | // | reset everything. |
25 | // (init) <------+ | But if the user wants to reset, | 21 | // (init) <------+ | But if the user wants to reset, |
26 | // | | | we stop dialing immediately. | 22 | // | | | we stop dialing immediately. |
27 | // v | | | 23 | // v | | |
28 | // (options) ----+ | Following the state machine is necessary | 24 | // (options) ----+ | Following the state machine is necessary |
29 | // | \ | to get determinable results. | 25 | // | \ | to get determinable results. |
30 | // v ^ | | 26 | // v ^ | |
31 | // (dial) ----+ | | 27 | // (dial) ----+ | |
32 | // | ^ | | 28 | // | ^ | |
33 | // v | | | 29 | // v | | |
34 | // (online) --+ | | 30 | // (online) --+ | |
35 | // | | | 31 | // | | |
36 | // v | | 32 | // v | |
37 | 33 | ||
38 | 34 | ||
39 | // from atconfigdialog | 35 | // from atconfigdialog |
40 | //initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); | 36 | //initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); |
41 | //resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); | 37 | //resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); |
42 | //dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 38 | //dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
43 | //dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 39 | //dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
44 | //dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 40 | //dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
45 | //dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 41 | //dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
46 | //dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); | 42 | //dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); |
47 | //dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); | 43 | //dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); |
48 | //connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); | 44 | //connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); |
49 | //hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); | 45 | //hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); |
50 | 46 | ||
51 | // from modemconfigwidget | 47 | // from modemconfigwidget |
52 | //int rad_flow = prof.readNumEntry("Flow"); | 48 | //int rad_flow = prof.readNumEntry("Flow"); |
53 | //int rad_parity = prof.readNumEntry("Parity"); | 49 | //int rad_parity = prof.readNumEntry("Parity"); |
54 | //int speed = prof.readNumEntry("Speed"); | 50 | //int speed = prof.readNumEntry("Speed"); |
55 | //QString number = prof.readEntry("Number"); | 51 | //QString number = prof.readEntry("Number"); |
56 | 52 | ||
57 | Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) | 53 | Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) |
58 | : QDialog(parent, name, true), m_fd(fd), m_profile(profile) | 54 | : QDialog(parent, name, true), m_fd(fd), m_profile(profile) |
59 | { | 55 | { |
60 | QVBoxLayout *vbox; | 56 | QVBoxLayout *vbox; |
61 | QLabel *desc; | 57 | QLabel *desc; |
62 | 58 | ||
63 | 59 | ||
64 | usercancel = 0; | 60 | usercancel = 0; |
65 | cleanshutdown = 0; | 61 | cleanshutdown = 0; |
66 | 62 | ||
67 | 63 | ||
68 | desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); | 64 | desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); |
69 | progress = new QProgressBar(this); | 65 | progress = new QProgressBar(this); |
70 | status = new QLabel("", this); | 66 | status = new QLabel("", this); |
71 | status->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 67 | status->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
72 | cancel = new QPushButton(QObject::tr("Cancel"), this); | 68 | cancel = new QPushButton(QObject::tr("Cancel"), this); |
73 | 69 | ||
74 | vbox = new QVBoxLayout(this, 2); | 70 | vbox = new QVBoxLayout(this, 2); |
75 | vbox->add(desc); | 71 | vbox->add(desc); |
76 | vbox->add(progress); | 72 | vbox->add(progress); |
77 | vbox->add(status); | 73 | vbox->add(status); |
78 | vbox->add(cancel); | 74 | vbox->add(cancel); |
79 | 75 | ||
80 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); | 76 | connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); |
81 | 77 | ||
82 | show(); | 78 | show(); |
83 | 79 | ||
84 | QTimer::singleShot(500, this, SLOT(slotAutostart())); | 80 | QTimer::singleShot(500, this, SLOT(slotAutostart())); |
85 | } | 81 | } |
86 | 82 | ||
87 | Dialer::~Dialer() | 83 | Dialer::~Dialer() |
88 | { | 84 | { |
89 | } | 85 | } |
90 | 86 | ||
91 | void Dialer::setHangupOnly() | 87 | void Dialer::setHangupOnly() |
92 | { | 88 | { |
93 | state = state_cancel; | 89 | state = state_cancel; |
94 | usercancel = 1; | 90 | usercancel = 1; |
95 | send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" ); | 91 | send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" ); |
96 | } | 92 | } |
97 | 93 | ||
98 | void Dialer::slotCancel() | 94 | void Dialer::slotCancel() |
99 | { | 95 | { |
100 | if(state != state_online) | 96 | if(state != state_online) |
101 | { | 97 | { |
102 | usercancel = 1; | 98 | usercancel = 1; |
103 | reset(); | 99 | reset(); |
104 | } | 100 | } |
105 | else { | 101 | else { |
106 | accept(); | 102 | accept(); |
107 | } | 103 | } |
108 | } | 104 | } |
109 | 105 | ||
110 | void Dialer::reset() | 106 | void Dialer::reset() |
111 | { | 107 | { |
112 | owarn << "reset" << oendl; | ||
113 | switchState(state_cancel); | 108 | switchState(state_cancel); |
114 | } | 109 | } |
115 | 110 | ||
116 | void Dialer::slotAutostart() | 111 | void Dialer::slotAutostart() |
117 | { | 112 | { |
118 | //state = state_preinit; | 113 | //state = state_preinit; |
119 | dial(m_profile.readEntry("Number")); | 114 | dial(m_profile.readEntry("Number")); |
120 | } | 115 | } |
121 | 116 | ||
122 | void Dialer::dial(const QString& number) | 117 | void Dialer::dial(const QString& number) |
123 | { | 118 | { |
124 | while(state != state_online) | 119 | while(state != state_online) |
125 | { | 120 | { |
126 | if(!usercancel) | 121 | if(!usercancel) |
127 | { | 122 | { |
128 | state = state_preinit; | 123 | state = state_preinit; |
129 | trydial(number); | 124 | trydial(number); |
130 | } | 125 | } |
131 | else break; | 126 | else break; |
132 | } | 127 | } |
133 | 128 | ||
134 | if(usercancel) | 129 | if(usercancel) |
135 | { | 130 | { |
136 | // modem hangup | 131 | // modem hangup |
137 | trydial(QString::null); | 132 | trydial(QString::null); |
138 | reject(); | 133 | reject(); |
139 | } | 134 | } |
140 | } | 135 | } |
141 | 136 | ||
142 | void Dialer::trydial(const QString& number) | 137 | void Dialer::trydial(const QString& number) |
143 | { | 138 | { |
144 | owarn << "TryDial:" << number.latin1() << "" << oendl; | ||
145 | if(state != state_cancel) switchState(state_preinit); | 139 | if(state != state_cancel) switchState(state_preinit); |
146 | if(cleanshutdown) | 140 | if(cleanshutdown) |
147 | { | 141 | { |
148 | owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl; | ||
149 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); | 142 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); |
150 | } | 143 | } |
151 | 144 | ||
152 | if(state != state_cancel) | 145 | if(state != state_cancel) |
153 | { | 146 | { |
154 | switchState(state_init); | 147 | switchState(state_init); |
155 | // owarn << "Init String " + m_profile.readEntry("InitString") << oendl; | ||
156 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); | 148 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); |
157 | QString response2 = receive(); | 149 | QString response2 = receive(); |
158 | if(!response2.contains("\nOK\r")) | 150 | if(!response2.contains("\nOK\r")) |
159 | reset(); | 151 | reset(); |
160 | } | 152 | } |
161 | 153 | ||
162 | /*if(state != state_cancel) | 154 | /*if(state != state_cancel) |
163 | { | 155 | { |
164 | switchState(state_options); | 156 | switchState(state_options); |
165 | 157 | ||
166 | owarn << "ATM3l3" << oendl; | 158 | owarn << "ATM3l3" << oendl; |
167 | send("ATM3L3\r"); | 159 | send("ATM3L3\r"); |
168 | QString response3 = receive(); | 160 | QString response3 = receive(); |
169 | if(!response3.contains("\nOK\r")) | 161 | if(!response3.contains("\nOK\r")) |
170 | reset(); | 162 | reset(); |
171 | } | 163 | } |
172 | */ | 164 | */ |
173 | 165 | ||
174 | if(state != state_cancel) | 166 | if(state != state_cancel) |
175 | { | 167 | { |
176 | switchState(state_dialtone); | 168 | switchState(state_dialtone); |
177 | 169 | ||
178 | send("ATX1\r"); | 170 | send("ATX1\r"); |
179 | QString response4 = receive(); | 171 | QString response4 = receive(); |
180 | if(!response4.contains("\nOK\r")) | 172 | if(!response4.contains("\nOK\r")) |
181 | reset(); | 173 | reset(); |
182 | } | 174 | } |
183 | 175 | ||
184 | if(state != state_cancel) | 176 | if(state != state_cancel) |
185 | { | 177 | { |
186 | owarn << "progress" << oendl; | ||
187 | switchState(state_dialing); | 178 | switchState(state_dialing); |
188 | 179 | ||
189 | // send(QString("ATDT %1\r").arg(number)); | 180 | // send(QString("ATDT %1\r").arg(number)); |
190 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) | 181 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) |
191 | .arg(number)); | 182 | .arg(number)); |
192 | 183 | ||
193 | QString response5 = receive(); | 184 | QString response5 = receive(); |
194 | if(!response5.contains("CONNECT") ) | 185 | if(!response5.contains("CONNECT") ) |
195 | { | 186 | { |
196 | if(response5.contains("BUSY")) | 187 | if(response5.contains("BUSY")) |
197 | switchState(state_dialing); | 188 | switchState(state_dialing); |
198 | else | 189 | else |
199 | { | 190 | { |
200 | QMessageBox::warning(this, | 191 | QMessageBox::warning(this, |
201 | QObject::tr("Failure"), | 192 | QObject::tr("Failure"), |
202 | QObject::tr("Dialing the number failed.")); | 193 | QObject::tr("<qt>Dialing the number failed.</qt>")); |
203 | slotCancel(); | 194 | slotCancel(); |
204 | } | 195 | } |
205 | } | 196 | } |
206 | } | 197 | } |
207 | 198 | ||
208 | 199 | ||
209 | if(state != state_cancel) | 200 | if(state != state_cancel) |
210 | { | 201 | { |
211 | state = state_online; | 202 | state = state_online; |
212 | slotCancel(); | 203 | slotCancel(); |
213 | } | 204 | } |
214 | } | 205 | } |
215 | 206 | ||
216 | void Dialer::send(const QString& msg) | 207 | void Dialer::send(const QString& msg) |
217 | { | 208 | { |
218 | QString m = msg; | 209 | QString m = msg; |
219 | int bytes; | 210 | int bytes; |
220 | QString termination; | 211 | QString termination; |
221 | 212 | ||
222 | owarn << "Sending: " << m.latin1() << "" << oendl; | ||
223 | 213 | ||
224 | /*termination = "\r"; | 214 | /*termination = "\r"; |
225 | //termination = m_profile.readEntry("Termination"); | 215 | //termination = m_profile.readEntry("Termination"); |
226 | if(termination == "\n") m = m + "\n"; | 216 | if(termination == "\n") m = m + "\n"; |
227 | else if(termination == "\r") m = m + "\r"; | 217 | else if(termination == "\r") m = m + "\r"; |
228 | else m = m + "\r\n"; | 218 | else m = m + "\r\n"; |
229 | */ | 219 | */ |
230 | m = m.replace(QRegExp("\n"), "\r"); | 220 | m = m.replace(QRegExp("\n"), "\r"); |
231 | 221 | ||
232 | bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); | 222 | bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); |
233 | if(bytes < 0) | 223 | if(bytes < 0) |
234 | { | 224 | { |
235 | reset(); | 225 | reset(); |
236 | } | 226 | } |
237 | } | 227 | } |
238 | 228 | ||
239 | QString Dialer::receive() | 229 | QString Dialer::receive() |
240 | { | 230 | { |
241 | QString buf; | 231 | QString buf; |
242 | char buffer[1024]; | 232 | char buffer[1024]; |
243 | int ret; | 233 | int ret; |
244 | int counter = 0; | 234 | int counter = 0; |
245 | 235 | ||
246 | while(1) | 236 | while(1) |
247 | { | 237 | { |
248 | ret = ::read(m_fd, buffer, sizeof(buffer)); | 238 | ret = ::read(m_fd, buffer, sizeof(buffer)); |
249 | 239 | ||
250 | if(ret > 0) | 240 | if(ret > 0) |
251 | { | 241 | { |
252 | for(int i = 0; i < ret; i++) | 242 | for(int i = 0; i < ret; i++) |
253 | buffer[i] = buffer[i] & 0x7F; | 243 | buffer[i] = buffer[i] & 0x7F; |
254 | buffer[ret] = 0; | 244 | buffer[ret] = 0; |
255 | owarn << "Got: " << buffer << "" << oendl; | ||
256 | buf.append(QString(buffer)); | 245 | buf.append(QString(buffer)); |
257 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) | 246 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) |
258 | { | 247 | { |
259 | //owarn << "Receiving: '" << buf.latin1() << "'" << oendl; | ||
260 | cleanshutdown = 1; | 248 | cleanshutdown = 1; |
261 | return buf; | 249 | return buf; |
262 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { | 250 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { |
263 | cleanshutdown = 1; | 251 | cleanshutdown = 1; |
264 | return QString::null; | 252 | return QString::null; |
265 | } | 253 | } |
266 | } | 254 | } |
267 | else if(ret < 0) | 255 | else if(ret < 0) |
268 | { | 256 | { |
269 | if(errno != EAGAIN) reset(); | 257 | if(errno != EAGAIN) reset(); |
270 | else if(!(counter++ % 100)) qApp->processEvents(); | 258 | else if(!(counter++ % 100)) qApp->processEvents(); |
271 | } | 259 | } |
272 | else if(!(counter++ % 100)) qApp->processEvents(); | 260 | else if(!(counter++ % 100)) qApp->processEvents(); |
273 | 261 | ||
274 | if(usercancel) return QString::null; | 262 | if(usercancel) return QString::null; |
275 | } | 263 | } |
276 | 264 | ||
277 | cleanshutdown = 1; | 265 | cleanshutdown = 1; |
278 | return QString::null; | 266 | return QString::null; |
279 | } | 267 | } |
280 | 268 | ||
281 | void Dialer::switchState(int newstate) | 269 | void Dialer::switchState(int newstate) |
282 | { | 270 | { |
283 | int oldstate = state; | 271 | int oldstate = state; |
284 | state = newstate; | 272 | state = newstate; |
285 | 273 | ||
286 | switch(state) | 274 | switch(state) |
287 | { | 275 | { |
288 | case state_cancel: | 276 | case state_cancel: |
289 | status->setText(QObject::tr("Cancelling...")); | 277 | status->setText(QObject::tr("Cancelling...")); |
290 | progress->setProgress(0); | 278 | progress->setProgress(0); |
291 | break; | 279 | break; |
292 | case state_preinit: | 280 | case state_preinit: |
293 | status->setText(QObject::tr("Searching modem")); | 281 | status->setText(QObject::tr("Searching modem")); |
294 | progress->setProgress(10); | 282 | progress->setProgress(10); |
295 | break; | 283 | break; |
296 | case state_init: | 284 | case state_init: |
297 | status->setText(QObject::tr("Initializing...")); | 285 | status->setText(QObject::tr("Initializing...")); |
298 | progress->setProgress(20); | 286 | progress->setProgress(20); |
299 | break; | 287 | break; |
300 | case state_options: | 288 | case state_options: |
301 | status->setText(QObject::tr("Reset speakers")); | 289 | status->setText(QObject::tr("Reset speakers")); |
302 | progress->setProgress(30); | 290 | progress->setProgress(30); |
303 | break; | 291 | break; |
304 | case state_dialtone: | 292 | case state_dialtone: |
305 | status->setText(QObject::tr("Turning off dialtone")); | 293 | status->setText(QObject::tr("Turning off dialtone")); |
306 | progress->setProgress(40); | 294 | progress->setProgress(40); |
307 | break; | 295 | break; |
308 | case state_dialing: | 296 | case state_dialing: |
309 | if(oldstate != state_dialing) status->setText(QObject::tr("Dial number")); | 297 | if(oldstate != state_dialing) status->setText(QObject::tr("Dial number")); |
310 | else status->setText(QObject::tr("Line busy, redialing number")); | 298 | else status->setText(QObject::tr("Line busy, redialing number")); |
311 | progress->setProgress(50); | 299 | progress->setProgress(50); |
312 | break; | 300 | break; |
313 | case state_online: | 301 | case state_online: |
314 | status->setText(QObject::tr("Connection established")); | 302 | status->setText(QObject::tr("Connection established")); |
315 | progress->setProgress(100); | 303 | progress->setProgress(100); |
316 | cancel->setText(QObject::tr("Dismiss")); | 304 | cancel->setText(QObject::tr("Dismiss")); |
317 | break; | 305 | break; |
318 | } | 306 | } |
319 | } | 307 | } |
320 | 308 | ||
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp index e045aef..986ae8d 100644 --- a/noncore/apps/opie-console/emulation_handler.cpp +++ b/noncore/apps/opie-console/emulation_handler.cpp | |||
@@ -1,247 +1,238 @@ | |||
1 | #include "TEmuVt102.h" | 1 | #include "TEmuVt102.h" |
2 | #include "profile.h" | 2 | #include "profile.h" |
3 | #include "emulation_handler.h" | 3 | #include "emulation_handler.h" |
4 | #include "script.h" | 4 | #include "script.h" |
5 | #include "logger.h" | 5 | #include "logger.h" |
6 | 6 | ||
7 | /* OPIE */ | ||
8 | #include <opie2/odebug.h> | ||
9 | |||
10 | #include <qfile.h> | 7 | #include <qfile.h> |
11 | #include <qtextstream.h> | 8 | #include <qtextstream.h> |
12 | 9 | ||
13 | using namespace Opie::Core; | ||
14 | |||
15 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) | 10 | EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) |
16 | : QObject(0, name ) | 11 | : QObject(0, name ) |
17 | { | 12 | { |
18 | m_teWid = new TEWidget( parent, "TerminalMain"); | 13 | m_teWid = new TEWidget( parent, "TerminalMain"); |
19 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) | 14 | // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) |
20 | // use setWrapAt(80) for normal console with scrollbar | 15 | // use setWrapAt(80) for normal console with scrollbar |
21 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); | 16 | setWrap(prof.readNumEntry("Wrap", 80) ? 0 : 80); |
22 | m_teWid->setMinimumSize(150, 70 ); | 17 | m_teWid->setMinimumSize(150, 70 ); |
23 | m_script = 0; | 18 | m_script = 0; |
24 | m_log = 0; | 19 | m_log = 0; |
25 | parent->resize( m_teWid->calcSize(80, 24 ) ); | 20 | parent->resize( m_teWid->calcSize(80, 24 ) ); |
26 | m_teEmu = new TEmuVt102(m_teWid ); | 21 | m_teEmu = new TEmuVt102(m_teWid ); |
27 | 22 | ||
28 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), | 23 | connect(m_teEmu,SIGNAL(ImageSizeChanged(int,int) ), |
29 | this, SIGNAL(changeSize(int,int) ) ); | 24 | this, SIGNAL(changeSize(int,int) ) ); |
30 | connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), | 25 | connect(m_teEmu, SIGNAL(sndBlock(const char*,int) ), |
31 | this, SLOT(recvEmulation(const char*,int) ) ); | 26 | this, SLOT(recvEmulation(const char*,int) ) ); |
32 | m_teEmu->setConnect( true ); | 27 | m_teEmu->setConnect( true ); |
33 | m_teEmu->setHistory( TRUE ); | 28 | m_teEmu->setHistory( TRUE ); |
34 | load( prof ); | 29 | load( prof ); |
35 | 30 | ||
36 | 31 | ||
37 | 32 | ||
38 | } | 33 | } |
39 | TEmulation* EmulationHandler::emulation() { | 34 | TEmulation* EmulationHandler::emulation() { |
40 | return m_teEmu; | 35 | return m_teEmu; |
41 | } | 36 | } |
42 | EmulationHandler::~EmulationHandler() { | 37 | EmulationHandler::~EmulationHandler() { |
43 | if (isRecording()) | 38 | if (isRecording()) |
44 | clearScript(); | 39 | clearScript(); |
45 | delete m_teEmu; | 40 | delete m_teEmu; |
46 | delete m_teWid; | 41 | delete m_teWid; |
47 | delete m_log; | 42 | delete m_log; |
48 | } | 43 | } |
49 | 44 | ||
50 | void EmulationHandler::load( const Profile& prof) { | 45 | void EmulationHandler::load( const Profile& prof) { |
51 | 46 | ||
52 | // m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); | 47 | // m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); |
53 | QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); | 48 | QFont font( prof.readEntry("Font"), prof.readNumEntry( "FontSize" ), QFont::Normal ); |
54 | font.setFixedPitch( TRUE ); | 49 | font.setFixedPitch( TRUE ); |
55 | m_teWid->setVTFont( font ); | 50 | m_teWid->setVTFont( font ); |
56 | 51 | ||
57 | int num = prof.readNumEntry("Color"); | 52 | int num = prof.readNumEntry("Color"); |
58 | setColor( foreColor(num), backColor(num) ); | 53 | setColor( foreColor(num), backColor(num) ); |
59 | m_teWid->setBackgroundColor(backColor(num) ); | 54 | m_teWid->setBackgroundColor(backColor(num) ); |
60 | 55 | ||
61 | int term = prof.readNumEntry("Terminal", 0) ; | 56 | int term = prof.readNumEntry("Terminal", 0) ; |
62 | switch(term) { | 57 | switch(term) { |
63 | default: | 58 | default: |
64 | case Profile::VT102: | 59 | case Profile::VT102: |
65 | case Profile::VT100: | 60 | case Profile::VT100: |
66 | m_teEmu->setKeytrans("vt100.keytab"); | 61 | m_teEmu->setKeytrans("vt100.keytab"); |
67 | break; | 62 | break; |
68 | case Profile::Linux: | 63 | case Profile::Linux: |
69 | m_teEmu->setKeytrans("linux.keytab"); | 64 | m_teEmu->setKeytrans("linux.keytab"); |
70 | break; | 65 | break; |
71 | case Profile::XTerm: | 66 | case Profile::XTerm: |
72 | m_teEmu->setKeytrans("default.Keytab"); | 67 | m_teEmu->setKeytrans("default.Keytab"); |
73 | break; | 68 | break; |
74 | } | 69 | } |
75 | } | 70 | } |
76 | void EmulationHandler::recv( const QByteArray& ar) { | 71 | void EmulationHandler::recv( const QByteArray& ar) { |
77 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); | 72 | m_teEmu->onRcvBlock(ar.data(), ar.count() ); |
78 | if ( isLogging() ) { | 73 | if ( isLogging() ) { |
79 | m_log->append( ar ); | 74 | m_log->append( ar ); |
80 | } | 75 | } |
81 | } | 76 | } |
82 | 77 | ||
83 | void EmulationHandler::recvEmulation(const char* src, int len ) { | 78 | void EmulationHandler::recvEmulation(const char* src, int len ) { |
84 | QByteArray ar(len); | 79 | QByteArray ar(len); |
85 | 80 | ||
86 | memcpy(ar.data(), src, sizeof(char) * len ); | 81 | memcpy(ar.data(), src, sizeof(char) * len ); |
87 | if (isRecording()) | 82 | if (isRecording()) |
88 | m_script->append(ar); | 83 | m_script->append(ar); |
89 | emit send(ar); | 84 | emit send(ar); |
90 | } | 85 | } |
91 | 86 | ||
92 | 87 | ||
93 | QWidget* EmulationHandler::widget() { | 88 | QWidget* EmulationHandler::widget() { |
94 | return m_teWid; | 89 | return m_teWid; |
95 | } | 90 | } |
96 | /* | 91 | /* |
97 | * allocate a new table of colors | 92 | * allocate a new table of colors |
98 | */ | 93 | */ |
99 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { | 94 | void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { |
100 | ColorEntry table[TABLE_COLORS]; | 95 | ColorEntry table[TABLE_COLORS]; |
101 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); | 96 | const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); |
102 | 97 | ||
103 | for (int i = 0; i < TABLE_COLORS; i++ ) { | 98 | for (int i = 0; i < TABLE_COLORS; i++ ) { |
104 | if ( i == 0 || i == 10 ) { | 99 | if ( i == 0 || i == 10 ) { |
105 | table[i].color = fore; | 100 | table[i].color = fore; |
106 | }else if ( i == 1 || i == 11 ) { | 101 | }else if ( i == 1 || i == 11 ) { |
107 | table[i].color = back; | 102 | table[i].color = back; |
108 | table[i].transparent = 0; | 103 | table[i].transparent = 0; |
109 | }else { | 104 | }else { |
110 | table[i].color = defaultCt[i].color; | 105 | table[i].color = defaultCt[i].color; |
111 | } | 106 | } |
112 | } | 107 | } |
113 | m_teWid->setColorTable(table ); | 108 | m_teWid->setColorTable(table ); |
114 | m_teWid->update(); | 109 | m_teWid->update(); |
115 | } | 110 | } |
116 | QFont EmulationHandler::font( int id ) { | 111 | QFont EmulationHandler::font( int id ) { |
117 | QString name; | 112 | QString name; |
118 | int size = 0; | 113 | int size = 0; |
119 | switch(id ) { | 114 | switch(id ) { |
120 | default: // fall through | 115 | default: // fall through |
121 | case 0: | 116 | case 0: |
122 | name = QString::fromLatin1("Micro"); | 117 | name = QString::fromLatin1("Micro"); |
123 | size = 4; | 118 | size = 4; |
124 | break; | 119 | break; |
125 | case 1: | 120 | case 1: |
126 | name = QString::fromLatin1("Fixed"); | 121 | name = QString::fromLatin1("Fixed"); |
127 | size = 7; | 122 | size = 7; |
128 | break; | 123 | break; |
129 | case 2: | 124 | case 2: |
130 | name = QString::fromLatin1("Fixed"); | 125 | name = QString::fromLatin1("Fixed"); |
131 | size = 12; | 126 | size = 12; |
132 | break; | 127 | break; |
133 | } | 128 | } |
134 | QFont font(name, size, QFont::Normal ); | 129 | QFont font(name, size, QFont::Normal ); |
135 | font.setFixedPitch(TRUE ); | 130 | font.setFixedPitch(TRUE ); |
136 | return font; | 131 | return font; |
137 | } | 132 | } |
138 | QColor EmulationHandler::foreColor(int col) { | 133 | QColor EmulationHandler::foreColor(int col) { |
139 | QColor co; | 134 | QColor co; |
140 | /* we need to switch it */ | 135 | /* we need to switch it */ |
141 | switch( col ) { | 136 | switch( col ) { |
142 | default: | 137 | default: |
143 | case Profile::White: | 138 | case Profile::White: |
144 | /* color is black */ | 139 | /* color is black */ |
145 | co = Qt::white; | 140 | co = Qt::white; |
146 | break; | 141 | break; |
147 | case Profile::Black: | 142 | case Profile::Black: |
148 | co = Qt::black; | 143 | co = Qt::black; |
149 | break; | 144 | break; |
150 | case Profile::Green: | 145 | case Profile::Green: |
151 | owarn << "Foreground green" << oendl; | ||
152 | co = Qt::green; | 146 | co = Qt::green; |
153 | break; | 147 | break; |
154 | case Profile::Orange: | 148 | case Profile::Orange: |
155 | owarn << "Foreground orange" << oendl; | ||
156 | co.setRgb( 231, 184, 98 ); | 149 | co.setRgb( 231, 184, 98 ); |
157 | break; | 150 | break; |
158 | } | 151 | } |
159 | 152 | ||
160 | return co; | 153 | return co; |
161 | } | 154 | } |
162 | QColor EmulationHandler::backColor(int col ) { | 155 | QColor EmulationHandler::backColor(int col ) { |
163 | QColor co; | 156 | QColor co; |
164 | /* we need to switch it */ | 157 | /* we need to switch it */ |
165 | switch( col ) { | 158 | switch( col ) { |
166 | default: | 159 | default: |
167 | case Profile::White: | 160 | case Profile::White: |
168 | /* color is white */ | 161 | /* color is white */ |
169 | co = Qt::black; | 162 | co = Qt::black; |
170 | break; | 163 | break; |
171 | case Profile::Black: | 164 | case Profile::Black: |
172 | co = Qt::white; | 165 | co = Qt::white; |
173 | break; | 166 | break; |
174 | case Profile::Green: | 167 | case Profile::Green: |
175 | owarn << "Background black" << oendl; | ||
176 | co = Qt::black; | 168 | co = Qt::black; |
177 | break; | 169 | break; |
178 | case Profile::Orange: | 170 | case Profile::Orange: |
179 | owarn << "Background black" << oendl; | ||
180 | co = Qt::black; | 171 | co = Qt::black; |
181 | break; | 172 | break; |
182 | } | 173 | } |
183 | 174 | ||
184 | return co; | 175 | return co; |
185 | } | 176 | } |
186 | 177 | ||
187 | QPushButton* EmulationHandler::cornerButton() { | 178 | QPushButton* EmulationHandler::cornerButton() { |
188 | return m_teWid->cornerButton(); | 179 | return m_teWid->cornerButton(); |
189 | } | 180 | } |
190 | 181 | ||
191 | 182 | ||
192 | Script *EmulationHandler::script() { | 183 | Script *EmulationHandler::script() { |
193 | return m_script; | 184 | return m_script; |
194 | } | 185 | } |
195 | 186 | ||
196 | bool EmulationHandler::isRecording() { | 187 | bool EmulationHandler::isRecording() { |
197 | return (m_script != 0); | 188 | return (m_script != 0); |
198 | } | 189 | } |
199 | 190 | ||
200 | bool EmulationHandler::isLogging() { | 191 | bool EmulationHandler::isLogging() { |
201 | return (m_log != 0); | 192 | return (m_log != 0); |
202 | } | 193 | } |
203 | 194 | ||
204 | void EmulationHandler::startRecording() { | 195 | void EmulationHandler::startRecording() { |
205 | if (!isRecording()) | 196 | if (!isRecording()) |
206 | m_script = new Script(); | 197 | m_script = new Script(); |
207 | } | 198 | } |
208 | 199 | ||
209 | void EmulationHandler::startLogging(const QString fileName) { | 200 | void EmulationHandler::startLogging(const QString fileName) { |
210 | m_logFileName = fileName; | 201 | m_logFileName = fileName; |
211 | if (!isLogging()) | 202 | if (!isLogging()) |
212 | m_log = new Logger(m_logFileName); | 203 | m_log = new Logger(m_logFileName); |
213 | } | 204 | } |
214 | 205 | ||
215 | QString EmulationHandler::logFileName() { | 206 | QString EmulationHandler::logFileName() { |
216 | return m_logFileName; | 207 | return m_logFileName; |
217 | } | 208 | } |
218 | 209 | ||
219 | void EmulationHandler::clearScript() { | 210 | void EmulationHandler::clearScript() { |
220 | if (isRecording()) { | 211 | if (isRecording()) { |
221 | delete m_script; | 212 | delete m_script; |
222 | m_script = 0; | 213 | m_script = 0; |
223 | } | 214 | } |
224 | } | 215 | } |
225 | 216 | ||
226 | void EmulationHandler::clearLog() { | 217 | void EmulationHandler::clearLog() { |
227 | if (isLogging()) { | 218 | if (isLogging()) { |
228 | delete m_log; | 219 | delete m_log; |
229 | m_log = 0; | 220 | m_log = 0; |
230 | } | 221 | } |
231 | } | 222 | } |
232 | 223 | ||
233 | void EmulationHandler::runScript(const Script *script) { | 224 | void EmulationHandler::runScript(const Script *script) { |
234 | emit send(script->script()); | 225 | emit send(script->script()); |
235 | } | 226 | } |
236 | 227 | ||
237 | void EmulationHandler::copy() { | 228 | void EmulationHandler::copy() { |
238 | m_teWid->emitSelection(); | 229 | m_teWid->emitSelection(); |
239 | } | 230 | } |
240 | void EmulationHandler::paste() { | 231 | void EmulationHandler::paste() { |
241 | m_teWid->pasteClipboard(); | 232 | m_teWid->pasteClipboard(); |
242 | } | 233 | } |
243 | 234 | ||
244 | void EmulationHandler::setWrap(int columns) { | 235 | void EmulationHandler::setWrap(int columns) { |
245 | m_teWid->setWrapAt(columns); | 236 | m_teWid->setWrapAt(columns); |
246 | } | 237 | } |
247 | 238 | ||
diff --git a/noncore/apps/opie-console/emulation_widget.cpp b/noncore/apps/opie-console/emulation_widget.cpp index 4688551..f0708d0 100644 --- a/noncore/apps/opie-console/emulation_widget.cpp +++ b/noncore/apps/opie-console/emulation_widget.cpp | |||
@@ -1,301 +1,295 @@ | |||
1 | // opie-console includes | 1 | // opie-console includes |
2 | #include "emulation_widget.h" | 2 | #include "emulation_widget.h" |
3 | 3 | ||
4 | // qt includes | 4 | // qt includes |
5 | #include <qscrollbar.h> | 5 | #include <qscrollbar.h> |
6 | 6 | ||
7 | #define rimX 0 // left/right rim width | 7 | #define rimX 0 // left/right rim width |
8 | #define rimY 0 // top/bottom rim high | 8 | #define rimY 0 // top/bottom rim high |
9 | 9 | ||
10 | static const ColorEntry color_table[TABLE_COLORS] = | 10 | static const ColorEntry color_table[TABLE_COLORS] = |
11 | { | 11 | { |
12 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | 12 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback |
13 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | 13 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red |
14 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | 14 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow |
15 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | 15 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta |
16 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | 16 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White |
17 | // intensiv | 17 | // intensiv |
18 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | 18 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), |
19 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | 19 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), |
20 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | 20 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), |
21 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | 21 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), |
22 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | 22 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) |
23 | }; | 23 | }; |
24 | 24 | ||
25 | EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) | 25 | EmulationWidget::EmulationWidget( const Profile& config, QWidget *parent, const char* name ) : WidgetLayer( config, parent, name ) |
26 | { | 26 | { |
27 | 27 | ||
28 | // initialize font attributes | 28 | // initialize font attributes |
29 | QFontMetrics fm( font() ); | 29 | QFontMetrics fm( font() ); |
30 | f_height = fm.height(); | 30 | f_height = fm.height(); |
31 | f_width = fm.maxWidth(); | 31 | f_width = fm.maxWidth(); |
32 | f_ascent = fm.ascent(); | 32 | f_ascent = fm.ascent(); |
33 | 33 | ||
34 | 34 | ||
35 | // initialize scrollbar related vars | 35 | // initialize scrollbar related vars |
36 | m_scrollbar = new QScrollBar( this ); | 36 | m_scrollbar = new QScrollBar( this ); |
37 | m_scrollbar->setCursor( arrowCursor ); | 37 | m_scrollbar->setCursor( arrowCursor ); |
38 | 38 | ||
39 | // give reasonable defaults to m_columns, m_lines | 39 | // give reasonable defaults to m_columns, m_lines |
40 | calcGeometry(); | 40 | calcGeometry(); |
41 | 41 | ||
42 | // load config | 42 | // load config |
43 | reloadConfig( config ); | 43 | reloadConfig( config ); |
44 | 44 | ||
45 | m_resizing = false; | 45 | m_resizing = false; |
46 | } | 46 | } |
47 | 47 | ||
48 | void EmulationWidget::reloadConfig( const Profile& config ) | 48 | void EmulationWidget::reloadConfig( const Profile& config ) |
49 | { | 49 | { |
50 | 50 | ||
51 | // nothing yet | 51 | // nothing yet |
52 | } | 52 | } |
53 | 53 | ||
54 | EmulationWidget::~EmulationWidget() | 54 | EmulationWidget::~EmulationWidget() |
55 | { | 55 | { |
56 | //clean up | 56 | //clean up |
57 | } | 57 | } |
58 | 58 | ||
59 | static QChar vt100extended(QChar c) | 59 | static QChar vt100extended(QChar c) |
60 | { | 60 | { |
61 | switch (c.unicode()) | 61 | switch (c.unicode()) |
62 | { | 62 | { |
63 | case 0x25c6 : return 1; | 63 | case 0x25c6 : return 1; |
64 | case 0x2592 : return 2; | 64 | case 0x2592 : return 2; |
65 | case 0x2409 : return 3; | 65 | case 0x2409 : return 3; |
66 | case 0x240c : return 4; | 66 | case 0x240c : return 4; |
67 | case 0x240d : return 5; | 67 | case 0x240d : return 5; |
68 | case 0x240a : return 6; | 68 | case 0x240a : return 6; |
69 | case 0x00b0 : return 7; | 69 | case 0x00b0 : return 7; |
70 | case 0x00b1 : return 8; | 70 | case 0x00b1 : return 8; |
71 | case 0x2424 : return 9; | 71 | case 0x2424 : return 9; |
72 | case 0x240b : return 10; | 72 | case 0x240b : return 10; |
73 | case 0x2518 : return 11; | 73 | case 0x2518 : return 11; |
74 | case 0x2510 : return 12; | 74 | case 0x2510 : return 12; |
75 | case 0x250c : return 13; | 75 | case 0x250c : return 13; |
76 | case 0x2514 : return 14; | 76 | case 0x2514 : return 14; |
77 | case 0x253c : return 15; | 77 | case 0x253c : return 15; |
78 | case 0xf800 : return 16; | 78 | case 0xf800 : return 16; |
79 | case 0xf801 : return 17; | 79 | case 0xf801 : return 17; |
80 | case 0x2500 : return 18; | 80 | case 0x2500 : return 18; |
81 | case 0xf803 : return 19; | 81 | case 0xf803 : return 19; |
82 | case 0xf804 : return 20; | 82 | case 0xf804 : return 20; |
83 | case 0x251c : return 21; | 83 | case 0x251c : return 21; |
84 | case 0x2524 : return 22; | 84 | case 0x2524 : return 22; |
85 | case 0x2534 : return 23; | 85 | case 0x2534 : return 23; |
86 | case 0x252c : return 24; | 86 | case 0x252c : return 24; |
87 | case 0x2502 : return 25; | 87 | case 0x2502 : return 25; |
88 | case 0x2264 : return 26; | 88 | case 0x2264 : return 26; |
89 | case 0x2265 : return 27; | 89 | case 0x2265 : return 27; |
90 | case 0x03c0 : return 28; | 90 | case 0x03c0 : return 28; |
91 | case 0x2260 : return 29; | 91 | case 0x2260 : return 29; |
92 | case 0x00a3 : return 30; | 92 | case 0x00a3 : return 30; |
93 | case 0x00b7 : return 31; | 93 | case 0x00b7 : return 31; |
94 | } | 94 | } |
95 | return c; | 95 | return c; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | QSize EmulationWidget::calcSize( int cols, int lins ) const | 99 | QSize EmulationWidget::calcSize( int cols, int lins ) const |
100 | { | 100 | { |
101 | int frw = width() - contentsRect().width(); | 101 | int frw = width() - contentsRect().width(); |
102 | 102 | ||
103 | int frh = height() - contentsRect().height(); | 103 | int frh = height() - contentsRect().height(); |
104 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); | 104 | int scw = (scrollLoc == SCRNONE? 0 : m_scrollbar->width() ); |
105 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); | 105 | return QSize( f_width * cols + 2 * rimX + frw + scw, f_height * lins + 2 * rimY + frh ); |
106 | } | 106 | } |
107 | 107 | ||
108 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) | 108 | void EmulationWidget::setImage( QArray<Character> const newimg, int lines, int columns ) |
109 | { | 109 | { |
110 | const QPixmap* pm = backgroundPixmap(); | 110 | const QPixmap* pm = backgroundPixmap(); |
111 | QPainter paint; | 111 | QPainter paint; |
112 | 112 | ||
113 | // dont allow updates, while drawing | 113 | // dont allow updates, while drawing |
114 | setUpdatesEnabled( false ); | 114 | setUpdatesEnabled( false ); |
115 | 115 | ||
116 | paint.begin( this ); | 116 | paint.begin( this ); |
117 | 117 | ||
118 | QPoint tL = contentsRect().topLeft(); | 118 | QPoint tL = contentsRect().topLeft(); |
119 | int tLx = tL.x(); | 119 | int tLx = tL.x(); |
120 | int tLy = tL.y(); | 120 | int tLy = tL.y(); |
121 | //hasBlinker = false; | 121 | //hasBlinker = false; |
122 | 122 | ||
123 | int cf = -1; | 123 | int cf = -1; |
124 | int cb = -1; | 124 | int cb = -1; |
125 | int cr = -1; | 125 | int cr = -1; |
126 | 126 | ||
127 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); | 127 | int lins = QMIN( m_lines, QMAX( 0, lines ) ); |
128 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); | 128 | int cols = QMIN( m_columns, QMAX( 0, columns ) ); |
129 | QArray<QChar> disstrU = QArray<QChar>( cols ); | 129 | QArray<QChar> disstrU = QArray<QChar>( cols ); |
130 | 130 | ||
131 | for ( int y = 0; y < lins; ++y ) | 131 | for ( int y = 0; y < lins; ++y ) |
132 | {int len; | 132 | {int len; |
133 | const Character* lcl = &m_image[y * m_columns]; | 133 | const Character* lcl = &m_image[y * m_columns]; |
134 | const Character* ext = &newimg[y * m_columns]; | 134 | const Character* ext = &newimg[y * m_columns]; |
135 | if ( ! m_resizing ) | 135 | if ( ! m_resizing ) |
136 | for ( int x = 0; x < cols; ++x ) | 136 | for ( int x = 0; x < cols; ++x ) |
137 | { | 137 | { |
138 | // disable, till widget works, WITHOUT blinking | 138 | // disable, till widget works, WITHOUT blinking |
139 | //hasBlinker |= ( ext[x].r & RE_BLINK ); | 139 | //hasBlinker |= ( ext[x].r & RE_BLINK ); |
140 | 140 | ||
141 | if ( ext[x] != lcl[x] ) | 141 | if ( ext[x] != lcl[x] ) |
142 | { | 142 | { |
143 | cr = ext[x].r; | 143 | cr = ext[x].r; |
144 | cb = ext[x].b; | 144 | cb = ext[x].b; |
145 | if ( ext[x].f != cf ) cf = ext[x].f; | 145 | if ( ext[x].f != cf ) cf = ext[x].f; |
146 | int lln = cols - x; | 146 | int lln = cols - x; |
147 | disstrU[0] = vt100extended( ext[x+0].c ); | 147 | disstrU[0] = vt100extended( ext[x+0].c ); |
148 | for ( len = 1; len < lln; ++len ) | 148 | for ( len = 1; len < lln; ++len ) |
149 | { | 149 | { |
150 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) | 150 | if ( ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || ext[x+len] == lcl[x+len] ) |
151 | break; | 151 | break; |
152 | disstrU[len] = vt100extended( ext[x+len].c ); | 152 | disstrU[len] = vt100extended( ext[x+len].c ); |
153 | } | 153 | } |
154 | QString unistr( disstrU, len ); | 154 | QString unistr( disstrU, len ); |
155 | drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); | 155 | drawAttrString( unistr, paint, QRect( m_blX+tLx+f_width*x, m_bY+tLy+f_height*y, f_width*len, f_height ), ext[x], pm != NULL, true ); |
156 | x += len -1; | 156 | x += len -1; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | // make image become newimg | 159 | // make image become newimg |
160 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); | 160 | memcpy( (void*) lcl, (const void*) ext, cols*sizeof( Character ) ); |
161 | } | 161 | } |
162 | drawFrame( &paint ); | 162 | drawFrame( &paint ); |
163 | paint.end(); | 163 | paint.end(); |
164 | setUpdatesEnabled( true ); | 164 | setUpdatesEnabled( true ); |
165 | 165 | ||
166 | /*if ( hasBlinker && !blinkT->isActive() ) | 166 | /*if ( hasBlinker && !blinkT->isActive() ) |
167 | blinkT->start(1000); //ms | 167 | blinkT->start(1000); //ms |
168 | if ( ! hasBlinker && blinkT->isActive() ) | 168 | if ( ! hasBlinker && blinkT->isActive() ) |
169 | { | 169 | { |
170 | blinkT->stop(); | 170 | blinkT->stop(); |
171 | blinking = false; | 171 | blinking = false; |
172 | }*/ | 172 | }*/ |
173 | 173 | ||
174 | delete [] disstrU; | 174 | delete [] disstrU; |
175 | } | 175 | } |
176 | 176 | ||
177 | 177 | ||
178 | void EmulationWidget::paintEvent( QPaintEvent* pe ) | 178 | void EmulationWidget::paintEvent( QPaintEvent* pe ) |
179 | { | 179 | { |
180 | QPainter painter; | 180 | QPainter painter; |
181 | const QPixmap* pm = backgroundPixmap(); | 181 | const QPixmap* pm = backgroundPixmap(); |
182 | 182 | ||
183 | painter.begin( this ); | 183 | painter.begin( this ); |
184 | painter.setBackgroundMode( TransparentMode ); | 184 | painter.setBackgroundMode( TransparentMode ); |
185 | 185 | ||
186 | QRect rect = pe->rect().intersect( contentsRect() ); | 186 | QRect rect = pe->rect().intersect( contentsRect() ); |
187 | QPoint tL = contentsRect().topLeft(); | 187 | QPoint tL = contentsRect().topLeft(); |
188 | int tLx = tL.x(); | 188 | int tLx = tL.x(); |
189 | int tLy = tL.y(); | 189 | int tLy = tL.y(); |
190 | 190 | ||
191 | int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); | 191 | int lux = QMIN(m_columns-1, QMAX(0,(rect.left() - tLx - m_blX ) / f_width)); |
192 | int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); | 192 | int luy = QMIN(m_lines-1, QMAX(0,(rect.top() - tLy - m_bY ) / f_height)); |
193 | int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); | 193 | int rlx = QMIN(m_columns-1, QMAX(0,(rect.right() - tLx - m_blX ) / f_width)); |
194 | int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); | 194 | int rly = QMIN(m_lines-1, QMAX(0,(rect.bottom() - tLy - m_bY ) / f_height)); |
195 | 195 | ||
196 | QChar *disstrU = new QChar[m_columns]; | 196 | QChar *disstrU = new QChar[m_columns]; |
197 | for (int y = luy; y <= rly; y++) | 197 | for (int y = luy; y <= rly; y++) |
198 | for (int x = lux; x <= rlx; x++) | 198 | for (int x = lux; x <= rlx; x++) |
199 | { | 199 | { |
200 | int len = 1; | 200 | int len = 1; |
201 | disstrU[0] = vt100extended(m_image[loc(x,y)].c); | 201 | disstrU[0] = vt100extended(m_image[loc(x,y)].c); |
202 | int cf = m_image[loc(x,y)].f; | 202 | int cf = m_image[loc(x,y)].f; |
203 | int cb = m_image[loc(x,y)].b; | 203 | int cb = m_image[loc(x,y)].b; |
204 | int cr = m_image[loc(x,y)].r; | 204 | int cr = m_image[loc(x,y)].r; |
205 | while (x+len <= rlx && | 205 | while (x+len <= rlx && |
206 | m_image[loc(x+len,y)].f == cf && | 206 | m_image[loc(x+len,y)].f == cf && |
207 | m_image[loc(x+len,y)].b == cb && | 207 | m_image[loc(x+len,y)].b == cb && |
208 | m_image[loc(x+len,y)].r == cr ) | 208 | m_image[loc(x+len,y)].r == cr ) |
209 | { | 209 | { |
210 | disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); | 210 | disstrU[len] = vt100extended(m_image[loc(x+len,y)].c); |
211 | len += 1; | 211 | len += 1; |
212 | } | 212 | } |
213 | QString unistr(disstrU,len); | 213 | QString unistr(disstrU,len); |
214 | 214 | ||
215 | drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false ); | 215 | drawAttrString( unistr, painter, QRect( m_blX+tLx+f_width*x,m_bY+tLy+f_height*y,f_width*len,f_height ), m_image[loc(x ,y )], pm != 0l, false ); |
216 | x +=len -1; | 216 | x +=len -1; |
217 | } | 217 | } |
218 | delete [] disstrU; | 218 | delete [] disstrU; |
219 | drawFrame( &painter ); | 219 | drawFrame( &painter ); |
220 | painter.end(); | 220 | painter.end(); |
221 | } | 221 | } |
222 | 222 | ||
223 | void EmulationWidget::calcGeometry() | 223 | void EmulationWidget::calcGeometry() |
224 | { | 224 | { |
225 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); | 225 | m_scrollbar->resize(QApplication::style().scrollBarExtent().width(), contentsRect().height() ); |
226 | 226 | ||
227 | odebug << QString(" TEST").arg( contentsRect().width() ) << oendl; | ||
228 | odebug << QString(" TEST").arg( contentsRect().height() ) << oendl; | ||
229 | odebug << "NEUER TESTT!!!!!!!!" << oendl; | ||
230 | |||
231 | switch( scrollLoc ) | 227 | switch( scrollLoc ) |
232 | { | 228 | { |
233 | case SCRNONE : | 229 | case SCRNONE : |
234 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; | 230 | m_columns = ( contentsRect().width() -2 * rimX ) / f_width; |
235 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; | 231 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) ) / 2; |
236 | m_brX = m_blX; | 232 | m_brX = m_blX; |
237 | m_scrollbar->hide(); | 233 | m_scrollbar->hide(); |
238 | break; | 234 | break; |
239 | case SCRLEFT : | 235 | case SCRLEFT : |
240 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 236 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
241 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 237 | m_brX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
242 | m_blX = m_brX + m_scrollbar->width(); | 238 | m_blX = m_brX + m_scrollbar->width(); |
243 | m_scrollbar->move( contentsRect().topLeft() ); | 239 | m_scrollbar->move( contentsRect().topLeft() ); |
244 | m_scrollbar->show(); | 240 | m_scrollbar->show(); |
245 | break; | 241 | break; |
246 | case SCRIGHT: | 242 | case SCRIGHT: |
247 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; | 243 | m_columns = ( contentsRect().width() - 2 * rimX - m_scrollbar->width() ) / f_width; |
248 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; | 244 | m_blX = ( contentsRect().width() - ( m_columns*f_width ) - m_scrollbar->width() ) / 2; |
249 | m_brX = m_blX; | 245 | m_brX = m_blX; |
250 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); | 246 | m_scrollbar->move( contentsRect().topRight() - QPoint (m_scrollbar->width()-1,0 ) ); |
251 | m_scrollbar->show(); | 247 | m_scrollbar->show(); |
252 | break; | 248 | break; |
253 | } | 249 | } |
254 | 250 | ||
255 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; | 251 | m_lines = ( contentsRect().height() - 2 * rimY ) / f_height; |
256 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; | 252 | m_bY = ( contentsRect().height() - (m_lines * f_height ) ) / 2; |
257 | } | 253 | } |
258 | 254 | ||
259 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) | 255 | void EmulationWidget::drawAttrString( QString& string, QPainter &painter, QRect rect, Character attr, bool usePixmap, bool clear ) |
260 | { | 256 | { |
261 | owarn << "Color1 " << color_table[attr.b].color.name().latin1() << "" << oendl; | ||
262 | if ( usePixmap && color_table[attr.b].transparent ) | 257 | if ( usePixmap && color_table[attr.b].transparent ) |
263 | { | 258 | { |
264 | painter.setBackgroundMode( TransparentMode ); | 259 | painter.setBackgroundMode( TransparentMode ); |
265 | if ( clear ) | 260 | if ( clear ) |
266 | erase( rect ); | 261 | erase( rect ); |
267 | } | 262 | } |
268 | else | 263 | else |
269 | { | 264 | { |
270 | if ( blinking ) | 265 | if ( blinking ) |
271 | painter.fillRect( rect, color_table[attr.b].color ); | 266 | painter.fillRect( rect, color_table[attr.b].color ); |
272 | else | 267 | else |
273 | { | 268 | { |
274 | painter.setBackgroundMode( OpaqueMode ); | 269 | painter.setBackgroundMode( OpaqueMode ); |
275 | owarn << "Color " << color_table[attr.b].color.name().latin1() << "" << oendl; | ||
276 | painter.setBackgroundColor( color_table[attr.b].color ); | 270 | painter.setBackgroundColor( color_table[attr.b].color ); |
277 | } | 271 | } |
278 | } | 272 | } |
279 | if ( color_table[attr.f].bold ) | 273 | if ( color_table[attr.f].bold ) |
280 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); | 274 | painter.setPen( QColor( 0x8F, 0x00, 0x00 ) ); |
281 | else | 275 | else |
282 | painter.setPen( color_table[attr.f].color ); | 276 | painter.setPen( color_table[attr.f].color ); |
283 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); | 277 | painter.drawText( rect.x(), rect.y() + f_ascent, string ); |
284 | 278 | ||
285 | } | 279 | } |
286 | 280 | ||
287 | 281 | ||
288 | /////////////////////// | 282 | /////////////////////// |
289 | // scrollbar | 283 | // scrollbar |
290 | // //////////////////// | 284 | // //////////////////// |
291 | 285 | ||
292 | void EmulationWidget::scroll( int value ) | 286 | void EmulationWidget::scroll( int value ) |
293 | { | 287 | { |
294 | } | 288 | } |
295 | 289 | ||
296 | void EmulationWidget::setScroll( int cursor, int slines ) | 290 | void EmulationWidget::setScroll( int cursor, int slines ) |
297 | { | 291 | { |
298 | } | 292 | } |
299 | 293 | ||
300 | 294 | ||
301 | 295 | ||
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 6613183..0abe0d9 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp | |||
@@ -1,431 +1,423 @@ | |||
1 | #include "function_keyboard.h" | 1 | #include "function_keyboard.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | /* QT */ | 3 | /* QT */ |
8 | #include <qlayout.h> | 4 | #include <qlayout.h> |
9 | #include <qlistbox.h> | 5 | #include <qlistbox.h> |
10 | #include <qlabel.h> | 6 | #include <qlabel.h> |
11 | #include <qdir.h> | 7 | #include <qdir.h> |
12 | 8 | ||
13 | #define DEFAULT_ROWS 2 | 9 | #define DEFAULT_ROWS 2 |
14 | #define DEFAULT_COLS 12 | 10 | #define DEFAULT_COLS 12 |
15 | 11 | ||
16 | /* FunctionKeyboard {{{1 */ | 12 | /* FunctionKeyboard {{{1 */ |
17 | 13 | ||
18 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : | 14 | FunctionKeyboard::FunctionKeyboard(QWidget *parent) : |
19 | QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), | 15 | QFrame(parent), numRows(DEFAULT_ROWS), numCols(DEFAULT_COLS), |
20 | pressedRow(0), pressedCol(0) { | 16 | pressedRow(0), pressedCol(0) { |
21 | 17 | ||
22 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); | 18 | setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); |
23 | 19 | ||
24 | /* | 20 | /* |
25 | * all the saving/loading is now done in a profile. downside is that you cant modify | 21 | * all the saving/loading is now done in a profile. downside is that you cant modify |
26 | * the keyboard for all profiles, but must do it on a profile-basis | 22 | * the keyboard for all profiles, but must do it on a profile-basis |
27 | * | 23 | * |
28 | 24 | ||
29 | Config conf("opie-console-keys"); | 25 | Config conf("opie-console-keys"); |
30 | conf.setGroup("keys"); | 26 | conf.setGroup("keys"); |
31 | for (uint r = 0; r < numRows; r++) | 27 | for (uint r = 0; r < numRows; r++) |
32 | for (uint c = 0; c < numCols; c++) { | 28 | for (uint c = 0; c < numCols; c++) { |
33 | 29 | ||
34 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 30 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
35 | QStringList value_list = conf.readListEntry( handle, '|'); | 31 | QStringList value_list = conf.readListEntry( handle, '|'); |
36 | 32 | ||
37 | if (value_list.isEmpty()) continue; | 33 | if (value_list.isEmpty()) continue; |
38 | 34 | ||
39 | keys.insert( | 35 | keys.insert( |
40 | 36 | ||
41 | handle, | 37 | handle, |
42 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) | 38 | FKey (value_list[0], value_list[1], value_list[2].toUShort(), value_list[3].toUShort()) |
43 | ); | 39 | ); |
44 | } | 40 | } |
45 | //owarn << "loaded " << keys.count() << " keys" << oendl; | ||
46 | */ | 41 | */ |
47 | if (keys.isEmpty()) loadDefaults(); | 42 | if (keys.isEmpty()) loadDefaults(); |
48 | 43 | ||
49 | 44 | ||
50 | 45 | ||
51 | } | 46 | } |
52 | 47 | ||
53 | FunctionKeyboard::~FunctionKeyboard() {} | 48 | FunctionKeyboard::~FunctionKeyboard() {} |
54 | 49 | ||
55 | void FunctionKeyboard::changeRows(int r) { | 50 | void FunctionKeyboard::changeRows(int r) { |
56 | 51 | ||
57 | numRows = r; | 52 | numRows = r; |
58 | 53 | ||
59 | // have to do this so the whole thing gets redrawn | 54 | // have to do this so the whole thing gets redrawn |
60 | hide(); show(); | 55 | hide(); show(); |
61 | } | 56 | } |
62 | void FunctionKeyboard::changeCols(int c) { | 57 | void FunctionKeyboard::changeCols(int c) { |
63 | 58 | ||
64 | numCols = c; | 59 | numCols = c; |
65 | keyWidth = (double)width()/numCols; // have to reset this thing too | 60 | keyWidth = (double)width()/numCols; // have to reset this thing too |
66 | repaint(false); | 61 | repaint(false); |
67 | } | 62 | } |
68 | void FunctionKeyboard::load (const Profile& prof) { | 63 | void FunctionKeyboard::load (const Profile& prof) { |
69 | 64 | ||
70 | keys.clear(); | 65 | keys.clear(); |
71 | 66 | ||
72 | numRows = prof.readNumEntry("keb_rows", 2); | 67 | numRows = prof.readNumEntry("keb_rows", 2); |
73 | numCols = prof.readNumEntry("keb_cols", 10); | 68 | numCols = prof.readNumEntry("keb_cols", 10); |
74 | keyWidth = (double)width()/numCols; // have to reset this thing too | 69 | keyWidth = (double)width()/numCols; // have to reset this thing too |
75 | 70 | ||
76 | /* load all the keys to the keyboard */ | 71 | /* load all the keys to the keyboard */ |
77 | for (ushort i = 0; i <= numRows - 1; i++) | 72 | for (ushort i = 0; i <= numRows - 1; i++) |
78 | for (ushort j = 0; j <= numCols - 1; j++) { | 73 | for (ushort j = 0; j <= numCols - 1; j++) { |
79 | 74 | ||
80 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | 75 | QString h = "r" + QString::number(i) + "c" + QString::number(j); |
81 | QString values = prof.readEntry("keb_" + h); | 76 | QString values = prof.readEntry("keb_" + h); |
82 | 77 | ||
83 | if (!values.isEmpty()) { | 78 | if (!values.isEmpty()) { |
84 | 79 | ||
85 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | 80 | QStringList l = QStringList::split(QChar('|'), values, TRUE); |
86 | keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | 81 | keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); |
87 | 82 | ||
88 | // load pixmap if used | 83 | // load pixmap if used |
89 | if (!l[1].isEmpty()) { | 84 | if (!l[1].isEmpty()) { |
90 | 85 | ||
91 | keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); | 86 | keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); |
92 | } | 87 | } |
93 | } | 88 | } |
94 | } | 89 | } |
95 | 90 | ||
96 | if (keys.isEmpty()) loadDefaults(); | 91 | if (keys.isEmpty()) loadDefaults(); |
97 | 92 | ||
98 | hide(); | 93 | hide(); |
99 | show(); | 94 | show(); |
100 | 95 | ||
101 | } | 96 | } |
102 | 97 | ||
103 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { | 98 | void FunctionKeyboard::paintEvent(QPaintEvent *e) { |
104 | 99 | ||
105 | QPainter p(this); | 100 | QPainter p(this); |
106 | p.setClipRect(e->rect()); | 101 | p.setClipRect(e->rect()); |
107 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); | 102 | p.fillRect(0, 0, width(), height(), QColor(255,255,255)); |
108 | 103 | ||
109 | p.setPen(QColor(0,0,0)); | 104 | p.setPen(QColor(0,0,0)); |
110 | 105 | ||
111 | /* those decimals do count! becomes short if use plain int */ | 106 | /* those decimals do count! becomes short if use plain int */ |
112 | for (double i = 0; i <= width(); i += keyWidth) { | 107 | for (double i = 0; i <= width(); i += keyWidth) { |
113 | 108 | ||
114 | p.drawLine((int)i, 0, (int)i, height()); | 109 | p.drawLine((int)i, 0, (int)i, height()); |
115 | } | 110 | } |
116 | 111 | ||
117 | // sometimes the last line doesnt get drawn | 112 | // sometimes the last line doesnt get drawn |
118 | p.drawLine(width() -1, 0, width() -1, height()); | 113 | p.drawLine(width() -1, 0, width() -1, height()); |
119 | 114 | ||
120 | for (int i = 0; i <= height(); i += keyHeight) { | 115 | for (int i = 0; i <= height(); i += keyHeight) { |
121 | 116 | ||
122 | p.drawLine(0, i, width(), i); | 117 | p.drawLine(0, i, width(), i); |
123 | } | 118 | } |
124 | 119 | ||
125 | for (uint r = 0; r < numRows; r++) { | 120 | for (uint r = 0; r < numRows; r++) { |
126 | for (uint c = 0; c < numCols; c++) { | 121 | for (uint c = 0; c < numCols; c++) { |
127 | 122 | ||
128 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); | 123 | QString handle = "r" + QString::number(r) + "c" + QString::number(c); |
129 | if (keys.contains(handle)) { | 124 | if (keys.contains(handle)) { |
130 | 125 | ||
131 | if (keys[handle].pixFile.isEmpty()) | 126 | if (keys[handle].pixFile.isEmpty()) |
132 | p.drawText( c * keyWidth + 1, r * keyHeight + 1, | 127 | p.drawText( c * keyWidth + 1, r * keyHeight + 1, |
133 | keyWidth, keyHeight, | 128 | keyWidth, keyHeight, |
134 | Qt::AlignHCenter | Qt::AlignVCenter, | 129 | Qt::AlignHCenter | Qt::AlignVCenter, |
135 | keys[handle].label | 130 | keys[handle].label |
136 | ); | 131 | ); |
137 | else { | 132 | else { |
138 | 133 | ||
139 | ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; | 134 | ushort centerX = (ushort)(c *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; |
140 | ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; | 135 | ushort centerY = r * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; |
141 | p.drawPixmap(centerX, centerY, *keys[handle].pix); | 136 | p.drawPixmap(centerX, centerY, *keys[handle].pix); |
142 | } | 137 | } |
143 | } | 138 | } |
144 | } | 139 | } |
145 | } | 140 | } |
146 | } | 141 | } |
147 | 142 | ||
148 | void FunctionKeyboard::paintKey(uint row, uint col) { | 143 | void FunctionKeyboard::paintKey(uint row, uint col) { |
149 | 144 | ||
150 | QPainter p(this); | 145 | QPainter p(this); |
151 | 146 | ||
152 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), | 147 | p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), |
153 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), | 148 | QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), |
154 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); | 149 | (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); |
155 | 150 | ||
156 | QString handle ("r" + QString::number(row) + "c" + QString::number(col)); | 151 | QString handle ("r" + QString::number(row) + "c" + QString::number(col)); |
157 | if (keys[handle].pixFile.isEmpty()) | 152 | if (keys[handle].pixFile.isEmpty()) |
158 | p.drawText( | 153 | p.drawText( |
159 | col * keyWidth + 1, row * keyHeight + 1, | 154 | col * keyWidth + 1, row * keyHeight + 1, |
160 | keyWidth, keyHeight, | 155 | keyWidth, keyHeight, |
161 | Qt::AlignHCenter | Qt::AlignVCenter, | 156 | Qt::AlignHCenter | Qt::AlignVCenter, |
162 | keys[handle].label | 157 | keys[handle].label |
163 | ); | 158 | ); |
164 | else { | 159 | else { |
165 | 160 | ||
166 | ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; | 161 | ushort centerX = (ushort)(col *keyWidth) + (ushort)(keyWidth - keys[handle].pix->width()) / 2; |
167 | ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; | 162 | ushort centerY = row * keyHeight + (keyHeight - keys[handle].pix->height()) / 2; |
168 | p.drawPixmap(centerX, centerY, *keys[handle].pix); | 163 | p.drawPixmap(centerX, centerY, *keys[handle].pix); |
169 | } | 164 | } |
170 | 165 | ||
171 | if (col == numCols - 1) { | 166 | if (col == numCols - 1) { |
172 | 167 | ||
173 | // sometimes it doesnt draw the last line | 168 | // sometimes it doesnt draw the last line |
174 | 169 | ||
175 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, | 170 | p.drawLine((col+1) * keyWidth -1, row * keyHeight, |
176 | (col+1) * keyWidth -1, (row + 1) * keyHeight | 171 | (col+1) * keyWidth -1, (row + 1) * keyHeight |
177 | ); | 172 | ); |
178 | } | 173 | } |
179 | 174 | ||
180 | } | 175 | } |
181 | 176 | ||
182 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { | 177 | void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { |
183 | 178 | ||
184 | pressedRow = e->y() / keyHeight; | 179 | pressedRow = e->y() / keyHeight; |
185 | pressedCol = (int) (e->x() / keyWidth); | 180 | pressedCol = (int) (e->x() / keyWidth); |
186 | 181 | ||
187 | paintKey(pressedRow, pressedCol); | 182 | paintKey(pressedRow, pressedCol); |
188 | 183 | ||
189 | // emit that sucker! | 184 | // emit that sucker! |
190 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; | 185 | FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; |
191 | emit keyPressed(k, pressedRow, pressedCol, 1); | 186 | emit keyPressed(k, pressedRow, pressedCol, 1); |
192 | 187 | ||
193 | } | 188 | } |
194 | 189 | ||
195 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { | 190 | void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { |
196 | 191 | ||
197 | if (pressedRow != -1 && pressedRow != -1) { | 192 | if (pressedRow != -1 && pressedRow != -1) { |
198 | 193 | ||
199 | int row = pressedRow; pressedRow = -1; | 194 | int row = pressedRow; pressedRow = -1; |
200 | int col = pressedCol; pressedCol = -1; | 195 | int col = pressedCol; pressedCol = -1; |
201 | paintKey(row, col); | 196 | paintKey(row, col); |
202 | 197 | ||
203 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; | 198 | FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; |
204 | emit keyPressed(k, row, col, 0); | 199 | emit keyPressed(k, row, col, 0); |
205 | } | 200 | } |
206 | 201 | ||
207 | } | 202 | } |
208 | 203 | ||
209 | 204 | ||
210 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { | 205 | void FunctionKeyboard::resizeEvent(QResizeEvent*) { |
211 | 206 | ||
212 | /* set he default font height/width */ | 207 | /* set he default font height/width */ |
213 | QFontMetrics fm=fontMetrics(); | 208 | QFontMetrics fm=fontMetrics(); |
214 | keyHeight = fm.lineSpacing() + 2; | 209 | keyHeight = fm.lineSpacing() + 2; |
215 | keyWidth = (double)width()/numCols; | 210 | keyWidth = (double)width()/numCols; |
216 | 211 | ||
217 | } | 212 | } |
218 | 213 | ||
219 | QSize FunctionKeyboard::sizeHint() const { | 214 | QSize FunctionKeyboard::sizeHint() const { |
220 | 215 | ||
221 | return QSize(width(), keyHeight * numRows + 1); | 216 | return QSize(width(), keyHeight * numRows + 1); |
222 | } | 217 | } |
223 | 218 | ||
224 | void FunctionKeyboard::loadDefaults() { | 219 | void FunctionKeyboard::loadDefaults() { |
225 | 220 | ||
226 | numRows = DEFAULT_ROWS; | 221 | numRows = DEFAULT_ROWS; |
227 | numCols = DEFAULT_COLS; | 222 | numCols = DEFAULT_COLS; |
228 | keyWidth = (double)width()/numCols; // have to reset this thing too | 223 | keyWidth = (double)width()/numCols; // have to reset this thing too |
229 | 224 | ||
230 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); | 225 | keys.insert( "r0c0", FKey ("Enter", "enter", Qt::Key_Enter, 0)); |
231 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); | 226 | keys.insert( "r0c1", FKey ("Space", "space", Qt::Key_Space, Qt::Key_Space)); |
232 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); | 227 | keys.insert( "r0c2", FKey ("Tab", "tab", Qt::Key_Tab, 0)); |
233 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); | 228 | keys.insert( "r0c3", FKey ("Up", "up", Qt::Key_Up, 0)); |
234 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); | 229 | keys.insert( "r0c4", FKey ("Down", "down", Qt::Key_Down, 0)); |
235 | 230 | ||
236 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); | 231 | keys.insert( "r0c7", FKey ("Ho", 0, 4112, 0)); |
237 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); | 232 | keys.insert( "r0c8", FKey ("End", 0, 4113, 0)); |
238 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); | 233 | keys.insert( "r0c9", FKey ("Pu", 0, 4118, 0)); |
239 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); | 234 | keys.insert( "r0c10", FKey ("Pd", 0, 4119, 0)); |
240 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); | 235 | keys.insert( "r0c11", FKey ("Esc", 0, Qt::Key_Escape, 0xfff)); |
241 | 236 | ||
242 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); | 237 | keys.insert( "r1c0", FKey ("F1", 0, 4144, 0)); |
243 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); | 238 | keys.insert( "r1c1", FKey ("F2", 0, 4145, 0)); |
244 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); | 239 | keys.insert( "r1c2", FKey ("F3", 0, 4146, 0)); |
245 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); | 240 | keys.insert( "r1c3", FKey ("F4", 0, 4147, 0)); |
246 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); | 241 | keys.insert( "r1c4", FKey ("F5", 0, 4148, 0)); |
247 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); | 242 | keys.insert( "r1c5", FKey ("F6", 0, 4149, 0)); |
248 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); | 243 | keys.insert( "r1c6", FKey ("F7", 0, 4150, 0)); |
249 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); | 244 | keys.insert( "r1c7", FKey ("F8", 0, 4151, 0)); |
250 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); | 245 | keys.insert( "r1c8", FKey ("F9", 0, 4152, 0)); |
251 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); | 246 | keys.insert( "r1c9", FKey ("F10", 0, 4153, 0)); |
252 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); | 247 | keys.insert( "r1c10", FKey ("F11", 0, 4154, 0)); |
253 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); | 248 | keys.insert( "r1c11", FKey ("F12", 0, 4155, 0)); |
254 | 249 | ||
255 | 250 | ||
256 | } | 251 | } |
257 | 252 | ||
258 | /* FunctionKeyboardConfig {{{1 */ | 253 | /* FunctionKeyboardConfig {{{1 */ |
259 | 254 | ||
260 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) | 255 | FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent, const char* na ) |
261 | : ProfileDialogKeyWidget(name, parent, na), | 256 | : ProfileDialogKeyWidget(name, parent, na), |
262 | selectedRow(0), selectedCol(0) | 257 | selectedRow(0), selectedCol(0) |
263 | { | 258 | { |
264 | owarn << "FunctionKeyboardConfig" << oendl; | ||
265 | |||
266 | |||
267 | kb = new FunctionKeyboard(this); | 259 | kb = new FunctionKeyboard(this); |
268 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), | 260 | connect (kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
269 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); | 261 | this, SLOT(slotKeyPressed(FKey,ushort,ushort,bool))); |
270 | 262 | ||
271 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); | 263 | QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimensions"), this); |
272 | QLabel *l = new QLabel("Rows", dimentions); | 264 | QLabel *l = new QLabel(tr("Rows"), dimentions); |
273 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); | 265 | m_rowBox = new QSpinBox(1, 15, 1, dimentions); |
274 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); | 266 | connect (m_rowBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeRows(int))); |
275 | l = new QLabel("Columns", dimentions); | 267 | l = new QLabel(tr("Columns"), dimentions); |
276 | m_colBox = new QSpinBox(1, 15, 1, dimentions); | 268 | m_colBox = new QSpinBox(1, 15, 1, dimentions); |
277 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); | 269 | connect (m_colBox, SIGNAL(valueChanged(int)), this, SLOT(slotChangeCols(int))); |
278 | 270 | ||
279 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); | 271 | QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit Key"), this); |
280 | l = new QLabel("Label", editKey); | 272 | l = new QLabel(tr("Label"), editKey); |
281 | m_labels = new QComboBox(true, editKey); | 273 | m_labels = new QComboBox(true, editKey); |
282 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); | 274 | m_labels->setInsertionPolicy(QComboBox::AtCurrent); |
283 | m_labels->insertItem(""); | 275 | m_labels->insertItem(""); |
284 | 276 | ||
285 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); | 277 | QStringList files = QDir( QPEApplication::qpeDir() + "pics/console/keys/", "*.png").entryList(); |
286 | 278 | ||
287 | for (uint i = 0; i < files.count(); i++) { | 279 | for (uint i = 0; i < files.count(); i++) { |
288 | 280 | ||
289 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); | 281 | m_labels->insertItem( Resource::loadPixmap("console/keys/" + files[i]), files[i]); |
290 | } | 282 | } |
291 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); | 283 | connect (m_labels, SIGNAL(activated(int)), this, SLOT(slotChangeIcon(int))); |
292 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); | 284 | connect (m_labels, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeLabelText(const QString&))); |
293 | 285 | ||
294 | l = new QLabel("Q Keycode", editKey); | 286 | l = new QLabel(tr("Q Keycode", "Qt Key Code for the OnScreen Keyboard"), editKey); |
295 | m_qvalues = new QComboBox(true, editKey); | 287 | m_qvalues = new QComboBox(true, editKey); |
296 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); | 288 | m_qvalues->setInsertionPolicy(QComboBox::AtTop); |
297 | m_qvalues->setDuplicatesEnabled(false); | 289 | m_qvalues->setDuplicatesEnabled(false); |
298 | m_qvalues->insertItem(""); | 290 | m_qvalues->insertItem(""); |
299 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); | 291 | connect (m_qvalues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeQCode(const QString&))); |
300 | 292 | ||
301 | l = new QLabel("Unicode Value", editKey); | 293 | l = new QLabel(tr("Unicode Value", "The Unicode value of the key"), editKey); |
302 | m_uniValues = new QComboBox(true, editKey); | 294 | m_uniValues = new QComboBox(true, editKey); |
303 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); | 295 | m_uniValues->setInsertionPolicy(QComboBox::AtTop); |
304 | m_uniValues->setDuplicatesEnabled(false); | 296 | m_uniValues->setDuplicatesEnabled(false); |
305 | m_uniValues->insertItem(""); | 297 | m_uniValues->insertItem(""); |
306 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); | 298 | connect (m_uniValues, SIGNAL(textChanged(const QString&)), this, SLOT(slotChangeUnicode(const QString&))); |
307 | 299 | ||
308 | QVBoxLayout *root = new QVBoxLayout(this, 2); | 300 | QVBoxLayout *root = new QVBoxLayout(this, 2); |
309 | root->addWidget(kb); | 301 | root->addWidget(kb); |
310 | root->addWidget(dimentions); | 302 | root->addWidget(dimentions); |
311 | root->addWidget(editKey); | 303 | root->addWidget(editKey); |
312 | } | 304 | } |
313 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { | 305 | FunctionKeyboardConfig::~FunctionKeyboardConfig() { |
314 | 306 | ||
315 | } | 307 | } |
316 | void FunctionKeyboardConfig::load (const Profile& prof) { | 308 | void FunctionKeyboardConfig::load (const Profile& prof) { |
317 | 309 | ||
318 | kb->keys.clear(); | 310 | kb->keys.clear(); |
319 | kb->loadDefaults(); | 311 | kb->loadDefaults(); |
320 | 312 | ||
321 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); | 313 | m_rowBox->setValue(prof.readNumEntry("keb_rows", 2)); |
322 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); | 314 | m_colBox->setValue(prof.readNumEntry("keb_cols", 10)); |
323 | 315 | ||
324 | /* load all the keys to the keyboard */ | 316 | /* load all the keys to the keyboard */ |
325 | for (int i = 0; i <= m_rowBox->value() -1; i++) | 317 | for (int i = 0; i <= m_rowBox->value() -1; i++) |
326 | for (int j = 0; j <= m_colBox->value() -1; j++) { | 318 | for (int j = 0; j <= m_colBox->value() -1; j++) { |
327 | 319 | ||
328 | QString h = "r" + QString::number(i) + "c" + QString::number(j); | 320 | QString h = "r" + QString::number(i) + "c" + QString::number(j); |
329 | QString values = prof.readEntry("keb_" + h); | 321 | QString values = prof.readEntry("keb_" + h); |
330 | 322 | ||
331 | if (!values.isEmpty()) { | 323 | if (!values.isEmpty()) { |
332 | 324 | ||
333 | QStringList l = QStringList::split(QChar('|'), values, TRUE); | 325 | QStringList l = QStringList::split(QChar('|'), values, TRUE); |
334 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); | 326 | kb->keys[h] = FKey(l[0], l[1], l[2].toInt(), l[3].toInt()); |
335 | 327 | ||
336 | // load pixmap if used | 328 | // load pixmap if used |
337 | if (!l[1].isEmpty()) { | 329 | if (!l[1].isEmpty()) { |
338 | 330 | ||
339 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); | 331 | kb->keys[h].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + l[1] ) ); |
340 | } | 332 | } |
341 | } | 333 | } |
342 | } | 334 | } |
343 | 335 | ||
344 | } | 336 | } |
345 | void FunctionKeyboardConfig::save (Profile& prof) { | 337 | void FunctionKeyboardConfig::save (Profile& prof) { |
346 | 338 | ||
347 | prof.writeEntry("keb_rows", m_rowBox->value()); | 339 | prof.writeEntry("keb_rows", m_rowBox->value()); |
348 | prof.writeEntry("keb_cols", m_colBox->value()); | 340 | prof.writeEntry("keb_cols", m_colBox->value()); |
349 | 341 | ||
350 | QMap<QString, FKey>::Iterator it; | 342 | QMap<QString, FKey>::Iterator it; |
351 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { | 343 | for ( it = kb->keys.begin(); it != kb->keys.end(); it++) { |
352 | 344 | ||
353 | FKey k = it.data(); | 345 | FKey k = it.data(); |
354 | QString entry = k.label + "|" | 346 | QString entry = k.label + "|" |
355 | + k.pixFile + "|" | 347 | + k.pixFile + "|" |
356 | + QString::number(k.qcode) + "|" | 348 | + QString::number(k.qcode) + "|" |
357 | + QString::number(k.unicode); | 349 | + QString::number(k.unicode); |
358 | 350 | ||
359 | prof.writeEntry("keb_" + it.key(), entry); | 351 | prof.writeEntry("keb_" + it.key(), entry); |
360 | 352 | ||
361 | } | 353 | } |
362 | 354 | ||
363 | } | 355 | } |
364 | void FunctionKeyboardConfig::slotChangeRows(int r) { | 356 | void FunctionKeyboardConfig::slotChangeRows(int r) { |
365 | 357 | ||
366 | kb->changeRows(r); | 358 | kb->changeRows(r); |
367 | 359 | ||
368 | } | 360 | } |
369 | void FunctionKeyboardConfig::slotChangeCols(int c) { | 361 | void FunctionKeyboardConfig::slotChangeCols(int c) { |
370 | 362 | ||
371 | kb->changeCols(c); | 363 | kb->changeCols(c); |
372 | } | 364 | } |
373 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { | 365 | void FunctionKeyboardConfig::slotKeyPressed(FKey k, ushort r, ushort c, bool pressed) { |
374 | 366 | ||
375 | if (!pressed) return; | 367 | if (!pressed) return; |
376 | 368 | ||
377 | selectedHandle = "r" + QString::number(r) + | 369 | selectedHandle = "r" + QString::number(r) + |
378 | "c" + QString::number(c); | 370 | "c" + QString::number(c); |
379 | selectedRow = r; | 371 | selectedRow = r; |
380 | selectedCol = c; | 372 | selectedCol = c; |
381 | 373 | ||
382 | if (k.pixFile.isEmpty()) { | 374 | if (k.pixFile.isEmpty()) { |
383 | 375 | ||
384 | m_labels->setEditable(true); | 376 | m_labels->setEditable(true); |
385 | m_labels->setCurrentItem(0); | 377 | m_labels->setCurrentItem(0); |
386 | m_labels->changeItem(k.label, 0); | 378 | m_labels->changeItem(k.label, 0); |
387 | 379 | ||
388 | } else { | 380 | } else { |
389 | 381 | ||
390 | // any better way to select the pixmap? | 382 | // any better way to select the pixmap? |
391 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); | 383 | m_labels->setCurrentItem((m_labels->listBox())->index((m_labels->listBox())->findItem(kb->keys[selectedHandle].pixFile))); |
392 | m_labels->setEditable(false); | 384 | m_labels->setEditable(false); |
393 | } | 385 | } |
394 | m_qvalues->changeItem(QString::number(k.qcode), 0); | 386 | m_qvalues->changeItem(QString::number(k.qcode), 0); |
395 | m_uniValues->changeItem(QString::number(k.unicode), 0); | 387 | m_uniValues->changeItem(QString::number(k.unicode), 0); |
396 | } | 388 | } |
397 | void FunctionKeyboardConfig::slotChangeIcon(int index) { | 389 | void FunctionKeyboardConfig::slotChangeIcon(int index) { |
398 | 390 | ||
399 | if (index == 0) { | 391 | if (index == 0) { |
400 | 392 | ||
401 | // is text | 393 | // is text |
402 | m_labels->setEditable(true); | 394 | m_labels->setEditable(true); |
403 | // why tf does the text get erased unless i do this? | 395 | // why tf does the text get erased unless i do this? |
404 | m_labels->changeItem(m_labels->text(0), 0); | 396 | m_labels->changeItem(m_labels->text(0), 0); |
405 | 397 | ||
406 | kb->keys[selectedHandle].pixFile = ""; | 398 | kb->keys[selectedHandle].pixFile = ""; |
407 | delete kb->keys[selectedHandle].pix; | 399 | delete kb->keys[selectedHandle].pix; |
408 | 400 | ||
409 | } else { | 401 | } else { |
410 | 402 | ||
411 | // is a pixmap | 403 | // is a pixmap |
412 | m_labels->setEditable(false); | 404 | m_labels->setEditable(false); |
413 | kb->keys[selectedHandle].pixFile = m_labels->currentText(); | 405 | kb->keys[selectedHandle].pixFile = m_labels->currentText(); |
414 | kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); | 406 | kb->keys[selectedHandle].pix = new QPixmap( Resource::loadPixmap( "console/keys/" + m_labels->currentText() ) ); |
415 | } | 407 | } |
416 | kb->paintKey(selectedRow, selectedCol); | 408 | kb->paintKey(selectedRow, selectedCol); |
417 | } | 409 | } |
418 | void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { | 410 | void FunctionKeyboardConfig::slotChangeLabelText(const QString &label) { |
419 | 411 | ||
420 | kb->keys[selectedHandle].label = label; | 412 | kb->keys[selectedHandle].label = label; |
421 | 413 | ||
422 | kb->paintKey(selectedRow, selectedCol); | 414 | kb->paintKey(selectedRow, selectedCol); |
423 | } | 415 | } |
424 | void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { | 416 | void FunctionKeyboardConfig::slotChangeQCode(const QString& qcode) { |
425 | 417 | ||
426 | kb->keys[selectedHandle].qcode = qcode.toUInt(); | 418 | kb->keys[selectedHandle].qcode = qcode.toUInt(); |
427 | } | 419 | } |
428 | void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { | 420 | void FunctionKeyboardConfig::slotChangeUnicode(const QString& uni) { |
429 | 421 | ||
430 | kb->keys[selectedHandle].unicode = uni.toUInt(); | 422 | kb->keys[selectedHandle].unicode = uni.toUInt(); |
431 | } | 423 | } |
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index c102427..a06b0c4 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -1,96 +1,79 @@ | |||
1 | 1 | ||
2 | #include "io_bt.h" | 2 | #include "io_bt.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
9 | m_attach = 0; | 5 | m_attach = 0; |
10 | } | 6 | } |
11 | 7 | ||
12 | 8 | ||
13 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
14 | if ( m_attach ) { | 10 | if ( m_attach ) { |
15 | delete m_attach; | 11 | delete m_attach; |
16 | } | 12 | } |
17 | } | 13 | } |
18 | 14 | ||
19 | 15 | ||
20 | void IOBt::close() { | 16 | void IOBt::close() { |
21 | 17 | ||
22 | IOSerial::close(); | 18 | IOSerial::close(); |
23 | // still need error handling | 19 | // still need error handling |
24 | if ( m_attach ) { | 20 | if ( m_attach ) { |
25 | delete m_attach; | 21 | delete m_attach; |
26 | m_attach = 0; | 22 | m_attach = 0; |
27 | } | 23 | } |
28 | } | 24 | } |
29 | 25 | ||
30 | bool IOBt::open() { | 26 | bool IOBt::open() { |
31 | bool ret = false; | 27 | bool ret = false; |
32 | 28 | ||
33 | // only set up bt stuff if mac address was set, otherwise use the device set | 29 | // only set up bt stuff if mac address was set, otherwise use the device set |
34 | if ( !m_mac.isEmpty() ) { | 30 | if ( !m_mac.isEmpty() ) { |
35 | 31 | ||
36 | // now it should also be checked, if there is a connection to the device with that mac allready | 32 | // now it should also be checked, if there is a connection to the device with that mac allready |
37 | // hciattach here | 33 | // hciattach here |
38 | m_attach = new OProcess(); | 34 | m_attach = new Opie::Core::OProcess(); |
39 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | 35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; |
40 | 36 | ||
41 | // then start hcid, then rcfomm handling (m_mac) | 37 | // then start hcid, then rcfomm handling (m_mac) |
42 | 38 | ||
43 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), | 39 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), |
44 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); | 40 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); |
45 | 41 | ||
46 | if ( m_attach->start() ) { | 42 | if ( m_attach->start() ) { |
47 | ret = IOSerial::open(); | 43 | ret = IOSerial::open(); |
48 | } else { | 44 | } else { |
49 | owarn << "could not attach to device" << oendl; | ||
50 | delete m_attach; | 45 | delete m_attach; |
51 | m_attach = 0; | 46 | m_attach = 0; |
52 | } | 47 | } |
53 | } else { | 48 | } else { |
54 | // directly to the normal serial | 49 | // directly to the normal serial |
55 | // TODO: look first if the connection really exists. ( is set up ) | 50 | // TODO: look first if the connection really exists. ( is set up ) |
56 | 51 | ||
57 | ret =IOSerial::open(); | 52 | ret =IOSerial::open(); |
58 | } | 53 | } |
59 | return ret; | 54 | return ret; |
60 | } | 55 | } |
61 | 56 | ||
62 | void IOBt::reload( const Profile &config ) { | 57 | void IOBt::reload( const Profile &config ) { |
63 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); | 58 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); |
64 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); | 59 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); |
65 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); | 60 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); |
66 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); | 61 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); |
67 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); | 62 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); |
68 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); | 63 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); |
69 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); | 64 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); |
70 | } | 65 | } |
71 | 66 | ||
72 | 67 | ||
73 | QString IOBt::identifier() const { | 68 | QString IOBt::identifier() const { |
74 | return "bluetooth"; | 69 | return "bluetooth"; |
75 | } | 70 | } |
76 | 71 | ||
77 | QString IOBt::name() const { | 72 | QString IOBt::name() const { |
78 | return "BLuetooth IO Layer"; | 73 | return "BLuetooth IO Layer"; |
79 | } | 74 | } |
80 | 75 | ||
81 | void IOBt::slotExited( OProcess* proc ){ | 76 | void IOBt::slotExited( Opie::Core::OProcess* proc ){ |
82 | close(); | 77 | close(); |
83 | delete proc; | 78 | delete proc; |
84 | } | 79 | } |
85 | |||
86 | QBitArray IOBt::supports() const { | ||
87 | return QBitArray( 3 ); | ||
88 | } | ||
89 | |||
90 | bool IOBt::isConnected() { | ||
91 | return false; | ||
92 | } | ||
93 | |||
94 | void IOBt::send(const QByteArray &data) { | ||
95 | odebug << "Please overload me..." << oendl; | ||
96 | } | ||
diff --git a/noncore/apps/opie-console/io_bt.h b/noncore/apps/opie-console/io_bt.h index 00ca7e5..156632b 100644 --- a/noncore/apps/opie-console/io_bt.h +++ b/noncore/apps/opie-console/io_bt.h | |||
@@ -1,51 +1,48 @@ | |||
1 | #ifndef OPIE_IO_BT | 1 | #ifndef OPIE_IO_BT |
2 | #define OPIE_IO_BT | 2 | #define OPIE_IO_BT |
3 | 3 | ||
4 | #include <opie2/oprocess.h> | 4 | #include <opie2/oprocess.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | /* Default values to be used if the profile information is incomplete */ | 7 | /* Default values to be used if the profile information is incomplete */ |
8 | #define BT_DEFAULT_DEVICE "/dev/ttyU0" | 8 | #define BT_DEFAULT_DEVICE "/dev/ttyU0" |
9 | #define BT_DEFAULT_BAUD 9600 | 9 | #define BT_DEFAULT_BAUD 9600 |
10 | #define BT_DEFAULT_PARITY 0 | 10 | #define BT_DEFAULT_PARITY 0 |
11 | #define BT_DEFAULT_DBITS 8 | 11 | #define BT_DEFAULT_DBITS 8 |
12 | #define BT_DEFAULT_SBITS 1 | 12 | #define BT_DEFAULT_SBITS 1 |
13 | #define BT_DEFAULT_FLOW 0 | 13 | #define BT_DEFAULT_FLOW 0 |
14 | #define BT_DEFAULT_MAC 0 | 14 | #define BT_DEFAULT_MAC 0 |
15 | 15 | ||
16 | 16 | ||
17 | /* IOSerial implements a RS232 IO Layer */ | 17 | /* IOSerial implements a RS232 IO Layer */ |
18 | 18 | ||
19 | class IOBt : public IOSerial { | 19 | class IOBt : public IOSerial { |
20 | 20 | ||
21 | Q_OBJECT | 21 | Q_OBJECT |
22 | 22 | ||
23 | public: | 23 | public: |
24 | 24 | ||
25 | IOBt(const Profile &); | 25 | IOBt(const Profile &); |
26 | ~IOBt(); | 26 | ~IOBt(); |
27 | 27 | ||
28 | virtual QString identifier() const; | 28 | virtual QString identifier() const; |
29 | virtual QString name() const; | 29 | virtual QString name() const; |
30 | virtual QBitArray supports() const; | ||
31 | virtual bool isConnected(); | ||
32 | 30 | ||
33 | signals: | 31 | signals: |
34 | void received(const QByteArray &); | 32 | void received(const QByteArray &); |
35 | void error(int, const QString &); | 33 | void error(int, const QString &); |
36 | 34 | ||
37 | public slots: | 35 | public slots: |
38 | virtual void send( const QByteArray& ); | ||
39 | virtual bool open(); | 36 | virtual bool open(); |
40 | virtual void close(); | 37 | virtual void close(); |
41 | virtual void reload(const Profile &); | 38 | virtual void reload(const Profile &); |
42 | 39 | ||
43 | private: | 40 | private: |
44 | Opie::Core::OProcess *m_attach; | 41 | Opie::Core::OProcess *m_attach; |
45 | QString m_mac; | 42 | QString m_mac; |
46 | private slots: | 43 | private slots: |
47 | void slotExited(Opie::Core::OProcess* proc); | 44 | void slotExited(Opie::Core::OProcess* proc); |
48 | 45 | ||
49 | }; | 46 | }; |
50 | 47 | ||
51 | #endif /* OPIE_IO_IRDA */ | 48 | #endif /* OPIE_IO_IRDA */ |
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index 38542f5..9d27c85 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp | |||
@@ -1,80 +1,64 @@ | |||
1 | #include "io_irda.h" | 1 | #include "io_irda.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | using namespace Opie::Core; | ||
6 | |||
7 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { | 3 | IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { |
8 | m_attach = 0; | 4 | m_attach = 0; |
9 | } | 5 | } |
10 | 6 | ||
11 | 7 | ||
12 | IOIrda::~IOIrda() { | 8 | IOIrda::~IOIrda() { |
13 | if ( m_attach ) { | 9 | if ( m_attach ) { |
14 | delete m_attach; | 10 | delete m_attach; |
15 | } | 11 | } |
16 | } | 12 | } |
17 | 13 | ||
18 | 14 | ||
19 | void IOIrda::close() { | 15 | void IOIrda::close() { |
20 | 16 | ||
21 | IOSerial::close(); | 17 | IOSerial::close(); |
22 | // still need error handling | 18 | // still need error handling |
23 | delete m_attach; | 19 | delete m_attach; |
24 | } | 20 | } |
25 | 21 | ||
26 | bool IOIrda::open() { | 22 | bool IOIrda::open() { |
27 | bool ret; | 23 | bool ret; |
28 | 24 | ||
29 | // irdaattach here | 25 | // irdaattach here |
30 | m_attach = new OProcess(); | 26 | m_attach = new Opie::Core::OProcess(); |
31 | *m_attach << "irattach /dev/ttyS2 -s"; | 27 | *m_attach << "irattach /dev/ttyS2 -s"; |
32 | 28 | ||
33 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), | 29 | connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), |
34 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); | 30 | this, SLOT( slotExited(Opie::Core::OProcess*) ) ); |
35 | 31 | ||
36 | if ( m_attach->start() ) { | 32 | if ( m_attach->start() ) { |
37 | ret= IOSerial::open(); | 33 | ret= IOSerial::open(); |
38 | } else { | 34 | } else { |
39 | // emit error!!! | 35 | // emit error!!! |
40 | owarn << "could not attach to device" << oendl; | ||
41 | delete m_attach; | 36 | delete m_attach; |
42 | m_attach = 0l; | 37 | m_attach = 0l; |
43 | } | 38 | } |
44 | return ret; | 39 | return ret; |
45 | } | 40 | } |
46 | 41 | ||
47 | void IOIrda::reload( const Profile &config ) { | 42 | void IOIrda::reload( const Profile &config ) { |
48 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); | 43 | m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); |
49 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); | 44 | m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); |
50 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); | 45 | m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); |
51 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); | 46 | m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); |
52 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); | 47 | m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); |
53 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); | 48 | m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); |
54 | } | 49 | } |
55 | 50 | ||
56 | 51 | ||
57 | QString IOIrda::identifier() const { | 52 | QString IOIrda::identifier() const { |
58 | return "irda"; | 53 | return "irda"; |
59 | } | 54 | } |
60 | 55 | ||
61 | QString IOIrda::name() const { | 56 | QString IOIrda::name() const { |
62 | return "Irda IO Layer"; | 57 | return "Irda IO Layer"; |
63 | } | 58 | } |
64 | 59 | ||
65 | void IOIrda::slotExited(OProcess* proc ){ | 60 | void IOIrda::slotExited(Opie::Core::OProcess* proc ){ |
66 | close(); | 61 | close(); |
67 | delete proc; | 62 | delete proc; |
68 | } | 63 | } |
69 | 64 | ||
70 | QBitArray IOIrda::supports()const { | ||
71 | return QBitArray( 3 ); | ||
72 | } | ||
73 | |||
74 | bool IOIrda::isConnected() { | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void IOIrda::send(const QByteArray &data) { | ||
79 | odebug << "Please overload me..." << oendl; | ||
80 | } | ||
diff --git a/noncore/apps/opie-console/io_irda.h b/noncore/apps/opie-console/io_irda.h index fb29686..1fdbd4b 100644 --- a/noncore/apps/opie-console/io_irda.h +++ b/noncore/apps/opie-console/io_irda.h | |||
@@ -1,49 +1,46 @@ | |||
1 | #ifndef OPIE_IO_IRDA | 1 | #ifndef OPIE_IO_IRDA |
2 | #define OPIE_IO_IRDA | 2 | #define OPIE_IO_IRDA |
3 | 3 | ||
4 | #include <opie2/oprocess.h> | 4 | #include <opie2/oprocess.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | /* Default values to be used if the profile information is incomplete */ | 7 | /* Default values to be used if the profile information is incomplete */ |
8 | #define IRDA_DEFAULT_DEVICE "/dev/ircomm0" | 8 | #define IRDA_DEFAULT_DEVICE "/dev/ircomm0" |
9 | #define IRDA_DEFAULT_BAUD 9600 | 9 | #define IRDA_DEFAULT_BAUD 9600 |
10 | #define IRDA_DEFAULT_PARITY 0 | 10 | #define IRDA_DEFAULT_PARITY 0 |
11 | #define IRDA_DEFAULT_DBITS 8 | 11 | #define IRDA_DEFAULT_DBITS 8 |
12 | #define IRDA_DEFAULT_SBITS 1 | 12 | #define IRDA_DEFAULT_SBITS 1 |
13 | #define IRDA_DEFAULT_FLOW 0 | 13 | #define IRDA_DEFAULT_FLOW 0 |
14 | 14 | ||
15 | /* IOSerial implements a RS232 IO Layer */ | 15 | /* IOSerial implements a RS232 IO Layer */ |
16 | 16 | ||
17 | class IOIrda : public IOSerial { | 17 | class IOIrda : public IOSerial { |
18 | 18 | ||
19 | Q_OBJECT | 19 | Q_OBJECT |
20 | 20 | ||
21 | public: | 21 | public: |
22 | 22 | ||
23 | IOIrda(const Profile &); | 23 | IOIrda(const Profile &); |
24 | ~IOIrda(); | 24 | ~IOIrda(); |
25 | 25 | ||
26 | virtual QString identifier() const; | 26 | virtual QString identifier() const; |
27 | virtual QString name() const; | 27 | virtual QString name() const; |
28 | virtual QBitArray supports() const; | ||
29 | virtual bool isConnected(); | ||
30 | 28 | ||
31 | signals: | 29 | signals: |
32 | void received(const QByteArray &); | 30 | void received(const QByteArray &); |
33 | void error(int, const QString &); | 31 | void error(int, const QString &); |
34 | 32 | ||
35 | public slots: | 33 | public slots: |
36 | virtual void send( const QByteArray& ); | ||
37 | virtual bool open(); | 34 | virtual bool open(); |
38 | virtual void close(); | 35 | virtual void close(); |
39 | virtual void reload(const Profile &); | 36 | virtual void reload(const Profile &); |
40 | 37 | ||
41 | private: | 38 | private: |
42 | Opie::Core::OProcess *m_attach; | 39 | Opie::Core::OProcess *m_attach; |
43 | 40 | ||
44 | private slots: | 41 | private slots: |
45 | void slotExited(Opie::Core::OProcess* proc); | 42 | void slotExited(Opie::Core::OProcess* proc); |
46 | 43 | ||
47 | }; | 44 | }; |
48 | 45 | ||
49 | #endif /* OPIE_IO_IRDA */ | 46 | #endif /* OPIE_IO_IRDA */ |
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index c499dfe..915a1d2 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp | |||
@@ -1,108 +1,86 @@ | |||
1 | 1 | ||
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | #include "dialer.h" | 3 | #include "dialer.h" |
4 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | using namespace Opie::Core; | ||
8 | |||
9 | IOModem::IOModem( const Profile &profile ) | 5 | IOModem::IOModem( const Profile &profile ) |
10 | : IOSerial( profile ) { | 6 | : IOSerial( profile ) { |
11 | m_profile = profile; | 7 | m_profile = profile; |
12 | } | 8 | } |
13 | 9 | ||
14 | 10 | ||
15 | IOModem::~IOModem() { | 11 | IOModem::~IOModem() { |
16 | } | 12 | } |
17 | 13 | ||
18 | 14 | ||
19 | void IOModem::close() { | 15 | void IOModem::close() { |
20 | // Hangup, discarding result | 16 | // Hangup, discarding result |
21 | //int fd = rawIO(); | 17 | //int fd = rawIO(); |
22 | internDetach(); | 18 | internDetach(); |
23 | Dialer d(m_profile, m_fd); | 19 | Dialer d(m_profile, m_fd); |
24 | d.setHangupOnly(); | 20 | d.setHangupOnly(); |
25 | //d.exec(); | 21 | //d.exec(); |
26 | internAttach(); | 22 | internAttach(); |
27 | //closeRawIO(fd); | 23 | //closeRawIO(fd); |
28 | 24 | ||
29 | IOSerial::close(); | 25 | IOSerial::close(); |
30 | } | 26 | } |
31 | 27 | ||
32 | bool IOModem::open() { | 28 | bool IOModem::open() { |
33 | bool ret = IOSerial::open(); | 29 | bool ret = IOSerial::open(); |
34 | if(!ret) return false; | 30 | if(!ret) return false; |
35 | 31 | ||
36 | //int fd = rawIO(); | 32 | //int fd = rawIO(); |
37 | internDetach(); | 33 | internDetach(); |
38 | Dialer d(m_profile, m_fd); | 34 | Dialer d(m_profile, m_fd); |
39 | 35 | ||
40 | int result = d.exec(); | 36 | int result = d.exec(); |
41 | internAttach(); | 37 | internAttach(); |
42 | //closeRawIO(fd); | 38 | //closeRawIO(fd); |
43 | if(result == QDialog::Accepted) | 39 | if(result == QDialog::Accepted) |
44 | { | 40 | { |
45 | return true; | 41 | return true; |
46 | } | 42 | } |
47 | else | 43 | else |
48 | { | 44 | { |
49 | close(); | 45 | close(); |
50 | return false; | 46 | return false; |
51 | } | 47 | } |
52 | } | 48 | } |
53 | 49 | ||
54 | void IOModem::reload( const Profile &config ) { | 50 | void IOModem::reload( const Profile &config ) { |
55 | 51 | ||
56 | m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); | 52 | m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); |
57 | m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); | 53 | m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); |
58 | m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); | 54 | m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); |
59 | m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); | 55 | m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); |
60 | m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); | 56 | m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); |
61 | m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); | 57 | m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); |
62 | 58 | ||
63 | m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); | 59 | m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); |
64 | m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); | 60 | m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); |
65 | m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); | 61 | m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); |
66 | m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 62 | m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
67 | m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); | 63 | m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); |
68 | m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 64 | m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
69 | m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); | 65 | m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); |
70 | m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 66 | m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
71 | m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); | 67 | m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); |
72 | m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); | 68 | m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); |
73 | m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); | 69 | m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); |
74 | m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); | 70 | m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); |
75 | m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); | 71 | m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); |
76 | m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); | 72 | m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); |
77 | m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); | 73 | m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); |
78 | m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); | 74 | m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); |
79 | m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); | 75 | m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); |
80 | m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); | 76 | m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); |
81 | } | 77 | } |
82 | 78 | ||
83 | 79 | ||
84 | QString IOModem::identifier() const { | 80 | QString IOModem::identifier() const { |
85 | return "modem"; | 81 | return "modem"; |
86 | } | 82 | } |
87 | 83 | ||
88 | QString IOModem::name() const { | 84 | QString IOModem::name() const { |
89 | return "Modem IO Layer"; | 85 | return "Modem IO Layer"; |
90 | } | 86 | } |
91 | |||
92 | void IOModem::slotExited(OProcess* proc ){ | ||
93 | close(); | ||
94 | /* delete it afterwards */ | ||
95 | delete proc; | ||
96 | } | ||
97 | |||
98 | QBitArray IOModem::supports()const { | ||
99 | return QBitArray( 3 ); | ||
100 | } | ||
101 | |||
102 | bool IOModem::isConnected() { | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | void IOModem::send(const QByteArray &data) { | ||
107 | odebug << "Please overload me..." << oendl; | ||
108 | } | ||
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index 5b99e00..056e630 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h | |||
@@ -1,74 +1,67 @@ | |||
1 | #ifndef OPIE_IO_MODEM | 1 | #ifndef OPIE_IO_MODEM |
2 | #define OPIE_IO_MODEM | 2 | #define OPIE_IO_MODEM |
3 | 3 | ||
4 | #include <opie2/oprocess.h> | 4 | #include <opie2/oprocess.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | 7 | ||
8 | /* Default values to be used if the profile information is incomplete */ | 8 | /* Default values to be used if the profile information is incomplete */ |
9 | #define MODEM_DEFAULT_DEVICE "/dev/ttyS0" | 9 | #define MODEM_DEFAULT_DEVICE "/dev/ttyS0" |
10 | #define MODEM_DEFAULT_BAUD 9600 | 10 | #define MODEM_DEFAULT_BAUD 9600 |
11 | #define MODEM_DEFAULT_PARITY 0 | 11 | #define MODEM_DEFAULT_PARITY 0 |
12 | #define MODEM_DEFAULT_DBITS 8 | 12 | #define MODEM_DEFAULT_DBITS 8 |
13 | #define MODEM_DEFAULT_SBITS 1 | 13 | #define MODEM_DEFAULT_SBITS 1 |
14 | #define MODEM_DEFAULT_FLOW 0 | 14 | #define MODEM_DEFAULT_FLOW 0 |
15 | 15 | ||
16 | #define MODEM_DEFAULT_INIT_STRING "AT" | 16 | #define MODEM_DEFAULT_INIT_STRING "AT" |
17 | #define MODEM_DEFAULT_RESET_STRING "ATZ~" | 17 | #define MODEM_DEFAULT_RESET_STRING "ATZ~" |
18 | #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" | 18 | #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" |
19 | #define MODEM_DEFAULT_DIAL_SUFFIX1 "" | 19 | #define MODEM_DEFAULT_DIAL_SUFFIX1 "" |
20 | #define MODEM_DEFAULT_DIAL_PREFIX2 "" | 20 | #define MODEM_DEFAULT_DIAL_PREFIX2 "" |
21 | #define MODEM_DEFAULT_DIAL_SUFFIX2 "" | 21 | #define MODEM_DEFAULT_DIAL_SUFFIX2 "" |
22 | #define MODEM_DEFAULT_DIAL_PREFIX3 "" | 22 | #define MODEM_DEFAULT_DIAL_PREFIX3 "" |
23 | #define MODEM_DEFAULT_DIAL_SUFFIX3 "" | 23 | #define MODEM_DEFAULT_DIAL_SUFFIX3 "" |
24 | #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" | 24 | #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" |
25 | #define MODEM_DEFAULT_HANGUP_STRING "+++ATH" | 25 | #define MODEM_DEFAULT_HANGUP_STRING "+++ATH" |
26 | #define MODEM_DEFAULT_CANCEL_STRING "" | 26 | #define MODEM_DEFAULT_CANCEL_STRING "" |
27 | #define MODEM_DEFAULT_DIAL_TIME 45 | 27 | #define MODEM_DEFAULT_DIAL_TIME 45 |
28 | #define MODEM_DEFAULT_DELAY_REDIAL 2 | 28 | #define MODEM_DEFAULT_DELAY_REDIAL 2 |
29 | #define MODEM_DEFAULT_NUMBER_TRIES 10 | 29 | #define MODEM_DEFAULT_NUMBER_TRIES 10 |
30 | #define MODEM_DEFAULT_DTR_DROP_TIME 1 | 30 | #define MODEM_DEFAULT_DTR_DROP_TIME 1 |
31 | #define MODEM_DEFAULT_BPS_DETECT 0 // bool | 31 | #define MODEM_DEFAULT_BPS_DETECT 0 // bool |
32 | #define MODEM_DEFAULT_DCD_LINES 1 //bool | 32 | #define MODEM_DEFAULT_DCD_LINES 1 //bool |
33 | #define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool | 33 | #define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool |
34 | 34 | ||
35 | /* IOSerial implements a RS232 IO Layer */ | 35 | /* IOSerial implements a RS232 IO Layer */ |
36 | 36 | ||
37 | class IOModem : public IOSerial { | 37 | class IOModem : public IOSerial { |
38 | 38 | ||
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | IOModem(const Profile &); | 43 | IOModem(const Profile &); |
44 | ~IOModem(); | 44 | ~IOModem(); |
45 | 45 | ||
46 | virtual QString identifier() const; | 46 | virtual QString identifier() const; |
47 | virtual QString name() const; | 47 | virtual QString name() const; |
48 | virtual QBitArray supports() const; | ||
49 | virtual bool isConnected(); | ||
50 | 48 | ||
51 | signals: | 49 | signals: |
52 | void received(const QByteArray &); | 50 | void received(const QByteArray &); |
53 | void error(int, const QString &); | 51 | void error(int, const QString &); |
54 | 52 | ||
55 | public slots: | 53 | public slots: |
56 | virtual void send( const QByteArray& ); | ||
57 | virtual bool open(); | 54 | virtual bool open(); |
58 | virtual void close(); | 55 | virtual void close(); |
59 | virtual void reload(const Profile &); | 56 | virtual void reload(const Profile &); |
60 | 57 | ||
61 | private: | 58 | private: |
62 | 59 | ||
63 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, | 60 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, |
64 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; | 61 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; |
65 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, | 62 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, |
66 | m_bpsDetect, m_dcdLines, m_multiLineUntag; | 63 | m_bpsDetect, m_dcdLines, m_multiLineUntag; |
67 | Profile m_profile; | 64 | Profile m_profile; |
68 | |||
69 | private slots: | ||
70 | void slotExited(Opie::Core::OProcess* proc); | ||
71 | |||
72 | }; | 65 | }; |
73 | 66 | ||
74 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 291912c..b3cb208 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,790 +1,783 @@ | |||
1 | #include "TEmulation.h" | 1 | #include "TEmulation.h" |
2 | #include "profileeditordialog.h" | 2 | #include "profileeditordialog.h" |
3 | #include "configdialog.h" | 3 | #include "configdialog.h" |
4 | #include "default.h" | 4 | #include "default.h" |
5 | #include "profilemanager.h" | 5 | #include "profilemanager.h" |
6 | #include "mainwindow.h" | 6 | #include "mainwindow.h" |
7 | #include "tabwidget.h" | 7 | #include "tabwidget.h" |
8 | #include "transferdialog.h" | 8 | #include "transferdialog.h" |
9 | #include "function_keyboard.h" | 9 | #include "function_keyboard.h" |
10 | #include "emulation_handler.h" | 10 | #include "emulation_handler.h" |
11 | #include "script.h" | 11 | #include "script.h" |
12 | #include "fixit.h" | 12 | #include "fixit.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | ||
16 | #include <opie2/ofiledialog.h> | 15 | #include <opie2/ofiledialog.h> |
17 | #include <qpe/filemanager.h> | 16 | #include <qpe/filemanager.h> |
18 | using namespace Opie::Core; | ||
19 | using namespace Opie::Ui; | 17 | using namespace Opie::Ui; |
20 | 18 | ||
21 | /* QT */ | 19 | /* QT */ |
22 | #include <qaction.h> | 20 | #include <qaction.h> |
23 | #include <qmenubar.h> | 21 | #include <qmenubar.h> |
24 | #include <qtoolbar.h> | 22 | #include <qtoolbar.h> |
25 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
26 | #include <qwhatsthis.h> | 24 | #include <qwhatsthis.h> |
27 | #include <qfileinfo.h> | 25 | #include <qfileinfo.h> |
28 | 26 | ||
29 | /* STD */ | 27 | /* STD */ |
30 | #include <assert.h> | 28 | #include <assert.h> |
31 | 29 | ||
32 | #ifdef EAST | 30 | #ifdef EAST |
33 | #include <opie2/oconfig.h> | 31 | #include <opie2/oconfig.h> |
34 | #endif | 32 | #endif |
35 | 33 | ||
36 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { | 34 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { |
37 | 35 | ||
38 | #ifdef FSCKED_DISTRI | 36 | #ifdef FSCKED_DISTRI |
39 | FixIt fix; | 37 | FixIt fix; |
40 | fix.fixIt(); | 38 | fix.fixIt(); |
41 | #endif | 39 | #endif |
42 | 40 | ||
43 | setCaption(QObject::tr("Opie Console") ); | 41 | setCaption(QObject::tr("Opie Console") ); |
44 | KeyTrans::loadAll(); | 42 | KeyTrans::loadAll(); |
45 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 43 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
46 | KeyTrans* s = KeyTrans::find(i ); | 44 | KeyTrans* s = KeyTrans::find(i ); |
47 | assert( s ); | 45 | assert( s ); |
48 | } | 46 | } |
49 | m_factory = new MetaFactory(); | 47 | m_factory = new MetaFactory(); |
50 | Default def(m_factory); | 48 | Default def(m_factory); |
51 | m_sessions.setAutoDelete( TRUE ); | 49 | m_sessions.setAutoDelete( TRUE ); |
52 | m_curSession = 0; | 50 | m_curSession = 0; |
53 | m_manager = new ProfileManager( m_factory ); | 51 | m_manager = new ProfileManager( m_factory ); |
54 | m_manager->load(); | 52 | m_manager->load(); |
55 | m_scriptsData.setAutoDelete(TRUE); | 53 | m_scriptsData.setAutoDelete(TRUE); |
56 | 54 | ||
57 | initUI(); | 55 | initUI(); |
58 | populateProfiles(); | 56 | populateProfiles(); |
59 | populateScripts(); | 57 | populateScripts(); |
60 | } | 58 | } |
61 | 59 | ||
62 | void MainWindow::initUI() { | 60 | void MainWindow::initUI() { |
63 | 61 | ||
64 | setToolBarsMovable( FALSE ); | 62 | setToolBarsMovable( FALSE ); |
65 | 63 | ||
66 | /* tool bar for the menu */ | 64 | /* tool bar for the menu */ |
67 | m_tool = new QToolBar( this ); | 65 | m_tool = new QToolBar( this ); |
68 | m_tool->setHorizontalStretchable( TRUE ); | 66 | m_tool->setHorizontalStretchable( TRUE ); |
69 | 67 | ||
70 | m_bar = new QMenuBar( m_tool ); | 68 | m_bar = new QMenuBar( m_tool ); |
71 | m_console = new QPopupMenu( this ); | 69 | m_console = new QPopupMenu( this ); |
72 | m_scripts = new QPopupMenu( this ); | 70 | m_scripts = new QPopupMenu( this ); |
73 | m_sessionsPop= new QPopupMenu( this ); | 71 | m_sessionsPop= new QPopupMenu( this ); |
74 | m_scriptsPop = new QPopupMenu( this ); | 72 | m_scriptsPop = new QPopupMenu( this ); |
75 | 73 | ||
76 | /* add a toolbar for icons */ | 74 | /* add a toolbar for icons */ |
77 | m_icons = new QToolBar(this); | 75 | m_icons = new QToolBar(this); |
78 | 76 | ||
79 | /* | 77 | /* |
80 | * the settings action | 78 | * the settings action |
81 | */ | 79 | */ |
82 | m_setProfiles = new QAction(tr("Configure Profiles"), | 80 | m_setProfiles = new QAction(tr("Configure Profiles"), |
83 | Resource::loadPixmap( "SettingsIcon" ), | 81 | Resource::loadPixmap( "SettingsIcon" ), |
84 | QString::null, 0, this, 0); | 82 | QString::null, 0, this, 0); |
85 | m_setProfiles->addTo( m_console ); | 83 | m_setProfiles->addTo( m_console ); |
86 | connect( m_setProfiles, SIGNAL(activated() ), | 84 | connect( m_setProfiles, SIGNAL(activated() ), |
87 | this, SLOT(slotConfigure() ) ); | 85 | this, SLOT(slotConfigure() ) ); |
88 | 86 | ||
89 | m_console->insertSeparator(); | 87 | m_console->insertSeparator(); |
90 | /* | 88 | /* |
91 | * new Action for new sessions | 89 | * new Action for new sessions |
92 | */ | 90 | */ |
93 | QAction* newCon = new QAction(tr("New Profile"), | 91 | QAction* newCon = new QAction(tr("New Profile"), |
94 | Resource::loadPixmap( "new" ), | 92 | Resource::loadPixmap( "new" ), |
95 | QString::null, 0, this, 0); | 93 | QString::null, 0, this, 0); |
96 | newCon->addTo( m_console ); | 94 | newCon->addTo( m_console ); |
97 | connect( newCon, SIGNAL(activated() ), | 95 | connect( newCon, SIGNAL(activated() ), |
98 | this, SLOT(slotNew() ) ); | 96 | this, SLOT(slotNew() ) ); |
99 | 97 | ||
100 | m_console->insertSeparator(); | 98 | m_console->insertSeparator(); |
101 | 99 | ||
102 | QAction *saveCon = new QAction( tr("Save Profile" ), | 100 | QAction *saveCon = new QAction( tr("Save Profile" ), |
103 | Resource::loadPixmap( "save" ), QString::null, | 101 | Resource::loadPixmap( "save" ), QString::null, |
104 | 0, this, 0 ); | 102 | 0, this, 0 ); |
105 | saveCon->addTo( m_console ); | 103 | saveCon->addTo( m_console ); |
106 | connect( saveCon, SIGNAL(activated() ), | 104 | connect( saveCon, SIGNAL(activated() ), |
107 | this, SLOT(slotSaveSession() ) ); | 105 | this, SLOT(slotSaveSession() ) ); |
108 | m_console->insertSeparator(); | 106 | m_console->insertSeparator(); |
109 | 107 | ||
110 | /* | 108 | /* |
111 | * connect action | 109 | * connect action |
112 | */ | 110 | */ |
113 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), | 111 | m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), |
114 | QString::null, 0, this, 0 ); | 112 | QString::null, 0, this, 0 ); |
115 | m_connect->addTo( m_console ); | 113 | m_connect->addTo( m_console ); |
116 | connect(m_connect, SIGNAL(activated() ), | 114 | connect(m_connect, SIGNAL(activated() ), |
117 | this, SLOT(slotConnect() ) ); | 115 | this, SLOT(slotConnect() ) ); |
118 | 116 | ||
119 | /* | 117 | /* |
120 | * disconnect action | 118 | * disconnect action |
121 | */ | 119 | */ |
122 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), | 120 | m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), |
123 | QString::null, 0, this, 0 ); | 121 | QString::null, 0, this, 0 ); |
124 | m_disconnect->addTo( m_console ); | 122 | m_disconnect->addTo( m_console ); |
125 | connect(m_disconnect, SIGNAL(activated() ), | 123 | connect(m_disconnect, SIGNAL(activated() ), |
126 | this, SLOT(slotDisconnect() ) ); | 124 | this, SLOT(slotDisconnect() ) ); |
127 | 125 | ||
128 | m_console->insertSeparator(); | 126 | m_console->insertSeparator(); |
129 | 127 | ||
130 | #ifndef EAST | 128 | #ifndef EAST |
131 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); | 129 | m_quickLaunch = new QAction( tr("QuickLaunch"), Resource::loadPixmap("console/konsole_mini"), QString::null, 0, this, 0 ); |
132 | m_quickLaunch->addTo( m_icons ); | 130 | m_quickLaunch->addTo( m_icons ); |
133 | connect( m_quickLaunch, SIGNAL( activated() ), | 131 | connect( m_quickLaunch, SIGNAL( activated() ), |
134 | this, SLOT( slotQuickLaunch() ) ); | 132 | this, SLOT( slotQuickLaunch() ) ); |
135 | #endif | 133 | #endif |
136 | 134 | ||
137 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); | 135 | QWhatsThis::add( m_icons, tr( "The shell button launches the \"default\" profile. If there is none default values are taken" ) ); |
138 | 136 | ||
139 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, | 137 | m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, |
140 | 0, this, 0 ); | 138 | 0, this, 0 ); |
141 | m_transfer->addTo( m_console ); | 139 | m_transfer->addTo( m_console ); |
142 | connect(m_transfer, SIGNAL(activated() ), | 140 | connect(m_transfer, SIGNAL(activated() ), |
143 | this, SLOT(slotTransfer() ) ); | 141 | this, SLOT(slotTransfer() ) ); |
144 | 142 | ||
145 | 143 | ||
146 | 144 | ||
147 | /* | 145 | /* |
148 | * immediate change of line wrap policy | 146 | * immediate change of line wrap policy |
149 | */ | 147 | */ |
150 | m_isWrapped = true; | 148 | m_isWrapped = true; |
151 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); | 149 | m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0, true ); |
152 | m_wrap->addTo( m_console ); | 150 | m_wrap->addTo( m_console ); |
153 | m_wrap->setOn( true ); | 151 | m_wrap->setOn( true ); |
154 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); | 152 | connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) ); |
155 | 153 | ||
156 | /* | 154 | /* |
157 | * fullscreen | 155 | * fullscreen |
158 | */ | 156 | */ |
159 | m_isFullscreen = false; | 157 | m_isFullscreen = false; |
160 | 158 | ||
161 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 159 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
162 | , QString::null, 0, this, 0 ); | 160 | , QString::null, 0, this, 0 ); |
163 | m_fullscreen->addTo( m_console ); | 161 | m_fullscreen->addTo( m_console ); |
164 | connect( m_fullscreen, SIGNAL( activated() ), | 162 | connect( m_fullscreen, SIGNAL( activated() ), |
165 | this, SLOT( slotFullscreen() ) ); | 163 | this, SLOT( slotFullscreen() ) ); |
166 | 164 | ||
167 | m_console->insertSeparator(); | 165 | m_console->insertSeparator(); |
168 | 166 | ||
169 | m_recordLog = new QAction(); | 167 | m_recordLog = new QAction(); |
170 | m_recordLog->setText( tr("Start log") ); | 168 | m_recordLog->setText( tr("Start log") ); |
171 | m_recordLog->addTo( m_console ); | 169 | m_recordLog->addTo( m_console ); |
172 | connect(m_recordLog, SIGNAL(activated() ), | 170 | connect(m_recordLog, SIGNAL(activated() ), |
173 | this, SLOT( slotSaveLog() ) ); | 171 | this, SLOT( slotSaveLog() ) ); |
174 | m_recordingLog = false; | 172 | m_recordingLog = false; |
175 | 173 | ||
176 | QAction *a = new QAction(); | 174 | QAction *a = new QAction(); |
177 | a->setText( tr("Save history") ); | 175 | a->setText( tr("Save history") ); |
178 | a->addTo( m_console ); | 176 | a->addTo( m_console ); |
179 | connect(a, SIGNAL(activated() ), | 177 | connect(a, SIGNAL(activated() ), |
180 | this, SLOT(slotSaveHistory() ) ); | 178 | this, SLOT(slotSaveHistory() ) ); |
181 | /* | 179 | /* |
182 | * terminate action | 180 | * terminate action |
183 | */ | 181 | */ |
184 | m_terminate = new QAction(); | 182 | m_terminate = new QAction(); |
185 | m_terminate->setText( tr("Terminate") ); | 183 | m_terminate->setText( tr("Terminate") ); |
186 | m_terminate->addTo( m_console ); | 184 | m_terminate->addTo( m_console ); |
187 | connect(m_terminate, SIGNAL(activated() ), | 185 | connect(m_terminate, SIGNAL(activated() ), |
188 | this, SLOT(slotTerminate() ) ); | 186 | this, SLOT(slotTerminate() ) ); |
189 | 187 | ||
190 | m_closewindow = new QAction(); | 188 | m_closewindow = new QAction(); |
191 | m_closewindow->setText( tr("Close Window") ); | 189 | m_closewindow->setText( tr("Close Window") ); |
192 | m_closewindow->addTo( m_console ); | 190 | m_closewindow->addTo( m_console ); |
193 | connect( m_closewindow, SIGNAL(activated() ), | 191 | connect( m_closewindow, SIGNAL(activated() ), |
194 | this, SLOT(slotClose() ) ); | 192 | this, SLOT(slotClose() ) ); |
195 | 193 | ||
196 | 194 | ||
197 | /* | 195 | /* |
198 | * script actions | 196 | * script actions |
199 | */ | 197 | */ |
200 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); | 198 | m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); |
201 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); | 199 | connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); |
202 | 200 | ||
203 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 201 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
204 | m_recordScript->addTo(m_scripts); | 202 | m_recordScript->addTo(m_scripts); |
205 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 203 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
206 | 204 | ||
207 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 205 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
208 | m_saveScript->addTo(m_scripts); | 206 | m_saveScript->addTo(m_scripts); |
209 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 207 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
210 | 208 | ||
211 | 209 | ||
212 | 210 | ||
213 | 211 | ||
214 | /* | 212 | /* |
215 | * action that open/closes the keyboard | 213 | * action that open/closes the keyboard |
216 | */ | 214 | */ |
217 | m_openKeys = new QAction (tr("Open Keyboard..."), | 215 | m_openKeys = new QAction (tr("Open Keyboard..."), |
218 | Resource::loadPixmap( "console/keys/keyboard_icon" ), | 216 | Resource::loadPixmap( "console/keys/keyboard_icon" ), |
219 | QString::null, 0, this, 0); | 217 | QString::null, 0, this, 0); |
220 | m_openKeys->setToggleAction(true); | 218 | m_openKeys->setToggleAction(true); |
221 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); | 219 | connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); |
222 | 220 | ||
223 | /* insert the submenu */ | 221 | /* insert the submenu */ |
224 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 222 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
225 | -1, 0); | 223 | -1, 0); |
226 | 224 | ||
227 | /* insert the connection menu */ | 225 | /* insert the connection menu */ |
228 | m_bar->insertItem( tr("Connection"), m_console ); | 226 | m_bar->insertItem( tr("Connection"), m_console ); |
229 | 227 | ||
230 | /* the scripts menu */ | 228 | /* the scripts menu */ |
231 | #ifdef EAST | 229 | #ifdef EAST |
232 | OConfig cfg("opie-console"); | 230 | OConfig cfg("opie-console"); |
233 | cfg.setGroup("10east"); | 231 | cfg.setGroup("10east"); |
234 | if( !cfg.readEntry("scripthide",0) ) { | 232 | if( !cfg.readEntry("scripthide",0) ) { |
235 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 233 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
236 | } | 234 | } |
237 | #endif | 235 | #endif |
238 | 236 | ||
239 | /* and the keyboard */ | 237 | /* and the keyboard */ |
240 | m_keyBar = new QToolBar(this); | 238 | m_keyBar = new QToolBar(this); |
241 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 239 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
242 | m_keyBar->setHorizontalStretchable( TRUE ); | 240 | m_keyBar->setHorizontalStretchable( TRUE ); |
243 | m_keyBar->hide(); | 241 | m_keyBar->hide(); |
244 | 242 | ||
245 | m_kb = new FunctionKeyboard(m_keyBar); | 243 | m_kb = new FunctionKeyboard(m_keyBar); |
246 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), | 244 | connect(m_kb, SIGNAL(keyPressed(FKey,ushort,ushort,bool)), |
247 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); | 245 | this, SLOT(slotKeyReceived(FKey,ushort,ushort,bool))); |
248 | 246 | ||
249 | 247 | ||
250 | a = new QAction(tr("Copy"), | 248 | a = new QAction(tr("Copy"), |
251 | Resource::loadPixmap("copy"), QString::null, | 249 | Resource::loadPixmap("copy"), QString::null, |
252 | 0, this, 0 ); | 250 | 0, this, 0 ); |
253 | //a->addTo( m_icons ); | 251 | //a->addTo( m_icons ); |
254 | connect( a, SIGNAL(activated() ), | 252 | connect( a, SIGNAL(activated() ), |
255 | this, SLOT(slotCopy() ) ); | 253 | this, SLOT(slotCopy() ) ); |
256 | 254 | ||
257 | QAction *paste = new QAction(tr("Paste"), | 255 | QAction *paste = new QAction(tr("Paste"), |
258 | Resource::loadPixmap("paste"), QString::null, | 256 | Resource::loadPixmap("paste"), QString::null, |
259 | 0, this, 0 ); | 257 | 0, this, 0 ); |
260 | connect( paste, SIGNAL(activated() ), | 258 | connect( paste, SIGNAL(activated() ), |
261 | this, SLOT(slotPaste() ) ); | 259 | this, SLOT(slotPaste() ) ); |
262 | 260 | ||
263 | 261 | ||
264 | newCon->addTo( m_icons ); | 262 | newCon->addTo( m_icons ); |
265 | //m_setProfiles->addTo( m_icons ); | 263 | //m_setProfiles->addTo( m_icons ); |
266 | paste->addTo( m_icons ); | 264 | paste->addTo( m_icons ); |
267 | m_openKeys->addTo(m_icons); | 265 | m_openKeys->addTo(m_icons); |
268 | m_fullscreen->addTo( m_icons ); | 266 | m_fullscreen->addTo( m_icons ); |
269 | 267 | ||
270 | m_connect->setEnabled( false ); | 268 | m_connect->setEnabled( false ); |
271 | m_disconnect->setEnabled( false ); | 269 | m_disconnect->setEnabled( false ); |
272 | m_terminate->setEnabled( false ); | 270 | m_terminate->setEnabled( false ); |
273 | m_transfer->setEnabled( false ); | 271 | m_transfer->setEnabled( false ); |
274 | m_scripts->setItemEnabled(m_runScript_id, false); | 272 | m_scripts->setItemEnabled(m_runScript_id, false); |
275 | m_recordScript->setEnabled( false ); | 273 | m_recordScript->setEnabled( false ); |
276 | m_saveScript->setEnabled( false ); | 274 | m_saveScript->setEnabled( false ); |
277 | m_fullscreen->setEnabled( false ); | 275 | m_fullscreen->setEnabled( false ); |
278 | m_closewindow->setEnabled( false ); | 276 | m_closewindow->setEnabled( false ); |
279 | m_wrap->setEnabled( false ); | 277 | m_wrap->setEnabled( false ); |
280 | 278 | ||
281 | /* | 279 | /* |
282 | * connect to the menu activation | 280 | * connect to the menu activation |
283 | */ | 281 | */ |
284 | connect( m_sessionsPop, SIGNAL(activated(int) ), | 282 | connect( m_sessionsPop, SIGNAL(activated(int) ), |
285 | this, SLOT(slotProfile(int) ) ); | 283 | this, SLOT(slotProfile(int) ) ); |
286 | 284 | ||
287 | m_consoleWindow = new TabWidget( this, "blah"); | 285 | m_consoleWindow = new TabWidget( this, "blah"); |
288 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 286 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
289 | this, SLOT(slotSessionChanged(Session*) ) ); | 287 | this, SLOT(slotSessionChanged(Session*) ) ); |
290 | setCentralWidget( m_consoleWindow ); | 288 | setCentralWidget( m_consoleWindow ); |
291 | 289 | ||
292 | slotQuickLaunch(); | 290 | slotQuickLaunch(); |
293 | } | 291 | } |
294 | 292 | ||
295 | ProfileManager* MainWindow::manager() { | 293 | ProfileManager* MainWindow::manager() { |
296 | return m_manager; | 294 | return m_manager; |
297 | } | 295 | } |
298 | TabWidget* MainWindow::tabWidget() { | 296 | TabWidget* MainWindow::tabWidget() { |
299 | return m_consoleWindow; | 297 | return m_consoleWindow; |
300 | } | 298 | } |
301 | void MainWindow::populateProfiles() { | 299 | void MainWindow::populateProfiles() { |
302 | m_sessionsPop->clear(); | 300 | m_sessionsPop->clear(); |
303 | Profile::ValueList list = manager()->all(); | 301 | Profile::ValueList list = manager()->all(); |
304 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 302 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
305 | m_sessionsPop->insertItem( (*it).name() ); | 303 | m_sessionsPop->insertItem( (*it).name() ); |
306 | } | 304 | } |
307 | 305 | ||
308 | } | 306 | } |
309 | 307 | ||
310 | void MainWindow::populateScripts() { | 308 | void MainWindow::populateScripts() { |
311 | m_scriptsPop->clear(); | 309 | m_scriptsPop->clear(); |
312 | m_scriptsData.clear(); | 310 | m_scriptsData.clear(); |
313 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); | 311 | DocLnkSet files(QPEApplication::documentDir(), "text/plain"); |
314 | QListIterator<DocLnk> dit(files.children()); | 312 | QListIterator<DocLnk> dit(files.children()); |
315 | for (; dit.current(); ++dit) { | 313 | for (; dit.current(); ++dit) { |
316 | if (*dit && (*dit)->name().length()>0) { | 314 | if (*dit && (*dit)->name().length()>0) { |
317 | QFileInfo info((*dit)->file()); | 315 | QFileInfo info((*dit)->file()); |
318 | if (info.extension(false) == "script") { | 316 | if (info.extension(false) == "script") { |
319 | m_scriptsData.append(new DocLnk(**dit)); | 317 | m_scriptsData.append(new DocLnk(**dit)); |
320 | m_scriptsPop->insertItem((*dit)->name()); | 318 | m_scriptsPop->insertItem((*dit)->name()); |
321 | } | 319 | } |
322 | } | 320 | } |
323 | } | 321 | } |
324 | 322 | ||
325 | } | 323 | } |
326 | 324 | ||
327 | MainWindow::~MainWindow() { | 325 | MainWindow::~MainWindow() { |
328 | delete m_factory; | 326 | delete m_factory; |
329 | manager()->save(); | 327 | manager()->save(); |
330 | #ifdef FSCKED_DISTRI | 328 | #ifdef FSCKED_DISTRI |
331 | FixIt fix; | 329 | FixIt fix; |
332 | fix.breakIt(); | 330 | fix.breakIt(); |
333 | #endif | 331 | #endif |
334 | } | 332 | } |
335 | 333 | ||
336 | MetaFactory* MainWindow::factory() { | 334 | MetaFactory* MainWindow::factory() { |
337 | return m_factory; | 335 | return m_factory; |
338 | } | 336 | } |
339 | 337 | ||
340 | Session* MainWindow::currentSession() { | 338 | Session* MainWindow::currentSession() { |
341 | return m_curSession; | 339 | return m_curSession; |
342 | } | 340 | } |
343 | 341 | ||
344 | QList<Session> MainWindow::sessions() { | 342 | QList<Session> MainWindow::sessions() { |
345 | return m_sessions; | 343 | return m_sessions; |
346 | } | 344 | } |
347 | 345 | ||
348 | void MainWindow::slotNew() { | 346 | void MainWindow::slotNew() { |
349 | ProfileEditorDialog dlg(factory() ); | 347 | ProfileEditorDialog dlg(factory() ); |
350 | dlg.setCaption( tr("New Connection") ); | 348 | dlg.setCaption( tr("New Connection") ); |
351 | int ret = QPEApplication::execDialog( &dlg ); | 349 | int ret = QPEApplication::execDialog( &dlg ); |
352 | 350 | ||
353 | if ( ret == QDialog::Accepted ) { | 351 | if ( ret == QDialog::Accepted ) { |
354 | create( dlg.profile() ); | 352 | create( dlg.profile() ); |
355 | } | 353 | } |
356 | } | 354 | } |
357 | 355 | ||
358 | void MainWindow::slotRecordScript() { | 356 | void MainWindow::slotRecordScript() { |
359 | if (currentSession()) { | 357 | if (currentSession()) { |
360 | currentSession()->emulationHandler()->startRecording(); | 358 | currentSession()->emulationHandler()->startRecording(); |
361 | m_saveScript->setEnabled(true); | 359 | m_saveScript->setEnabled(true); |
362 | m_recordScript->setEnabled(false); | 360 | m_recordScript->setEnabled(false); |
363 | } | 361 | } |
364 | } | 362 | } |
365 | 363 | ||
366 | void MainWindow::slotSaveScript() { | 364 | void MainWindow::slotSaveScript() { |
367 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { | 365 | if (currentSession() && currentSession()->emulationHandler()->isRecording()) { |
368 | QMap<QString, QStringList> map; | 366 | QMap<QString, QStringList> map; |
369 | QStringList text; | 367 | QStringList text; |
370 | text << "text/plain"; | 368 | text << "text/plain"; |
371 | map.insert(tr("Script"), text ); | 369 | map.insert(tr("Script"), text ); |
372 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 370 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
373 | if (!filename.isEmpty()) { | 371 | if (!filename.isEmpty()) { |
374 | QFileInfo info(filename); | 372 | QFileInfo info(filename); |
375 | if (info.extension(FALSE) != "script") | 373 | if (info.extension(FALSE) != "script") |
376 | filename += ".script"; | 374 | filename += ".script"; |
377 | DocLnk nf; | 375 | DocLnk nf; |
378 | nf.setType("text/plain"); | 376 | nf.setType("text/plain"); |
379 | nf.setFile(filename); | 377 | nf.setFile(filename); |
380 | nf.setName(info.fileName()); | 378 | nf.setName(info.fileName()); |
381 | FileManager fm; | 379 | FileManager fm; |
382 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); | 380 | fm.saveFile(nf, currentSession()->emulationHandler()->script()->script()); |
383 | currentSession()->emulationHandler()->clearScript(); | 381 | currentSession()->emulationHandler()->clearScript(); |
384 | m_saveScript->setEnabled(false); | 382 | m_saveScript->setEnabled(false); |
385 | m_recordScript->setEnabled(true); | 383 | m_recordScript->setEnabled(true); |
386 | populateScripts(); | 384 | populateScripts(); |
387 | } | 385 | } |
388 | } | 386 | } |
389 | } | 387 | } |
390 | 388 | ||
391 | void MainWindow::slotRunScript(int id) { | 389 | void MainWindow::slotRunScript(int id) { |
392 | if (currentSession()) { | 390 | if (currentSession()) { |
393 | int index = m_scriptsPop->indexOf(id); | 391 | int index = m_scriptsPop->indexOf(id); |
394 | DocLnk *lnk = m_scriptsData.at(index); | 392 | DocLnk *lnk = m_scriptsData.at(index); |
395 | QString filePath = lnk->file(); | 393 | QString filePath = lnk->file(); |
396 | Script script(filePath); | 394 | Script script(filePath); |
397 | currentSession()->emulationHandler()->runScript(&script); | 395 | currentSession()->emulationHandler()->runScript(&script); |
398 | } | 396 | } |
399 | } | 397 | } |
400 | 398 | ||
401 | void MainWindow::slotConnect() { | 399 | void MainWindow::slotConnect() { |
402 | if ( currentSession() ) { | 400 | if ( currentSession() ) { |
403 | bool ret = currentSession()->layer()->open(); | 401 | bool ret = currentSession()->layer()->open(); |
404 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 402 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
405 | QObject::tr("Failed"), | 403 | QObject::tr("Failed"), |
406 | QObject::tr("Connecting failed for this session.")); | 404 | QObject::tr("Connecting failed for this session.")); |
407 | else { | 405 | else { |
408 | m_connect->setEnabled( false ); | 406 | m_connect->setEnabled( false ); |
409 | m_disconnect->setEnabled( true ); | 407 | m_disconnect->setEnabled( true ); |
410 | 408 | ||
411 | // if it does not support file transfer, disable the menu entry | 409 | // if it does not support file transfer, disable the menu entry |
412 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 410 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
413 | m_transfer->setEnabled( false ); | 411 | m_transfer->setEnabled( false ); |
414 | } else { | 412 | } else { |
415 | m_transfer->setEnabled( true ); | 413 | m_transfer->setEnabled( true ); |
416 | } | 414 | } |
417 | 415 | ||
418 | m_recordScript->setEnabled( true ); | 416 | m_recordScript->setEnabled( true ); |
419 | m_scripts->setItemEnabled(m_runScript_id, true); | 417 | m_scripts->setItemEnabled(m_runScript_id, true); |
420 | } | 418 | } |
421 | } | 419 | } |
422 | } | 420 | } |
423 | 421 | ||
424 | void MainWindow::slotDisconnect() { | 422 | void MainWindow::slotDisconnect() { |
425 | if ( currentSession() ) { | 423 | if ( currentSession() ) { |
426 | currentSession()->layer()->close(); | 424 | currentSession()->layer()->close(); |
427 | m_connect->setEnabled( true ); | 425 | m_connect->setEnabled( true ); |
428 | m_disconnect->setEnabled( false ); | 426 | m_disconnect->setEnabled( false ); |
429 | m_transfer->setEnabled( false ); | 427 | m_transfer->setEnabled( false ); |
430 | m_recordScript->setEnabled( false); | 428 | m_recordScript->setEnabled( false); |
431 | m_saveScript->setEnabled( false ); | 429 | m_saveScript->setEnabled( false ); |
432 | m_scripts->setItemEnabled(m_runScript_id, false); | 430 | m_scripts->setItemEnabled(m_runScript_id, false); |
433 | } | 431 | } |
434 | } | 432 | } |
435 | 433 | ||
436 | void MainWindow::slotTerminate() { | 434 | void MainWindow::slotTerminate() { |
437 | if ( currentSession() ) | 435 | if ( currentSession() ) |
438 | currentSession()->layer()->close(); | 436 | currentSession()->layer()->close(); |
439 | 437 | ||
440 | slotClose(); | 438 | slotClose(); |
441 | /* FIXME move to the next session */ | 439 | /* FIXME move to the next session */ |
442 | } | 440 | } |
443 | 441 | ||
444 | 442 | ||
445 | 443 | ||
446 | void MainWindow::slotQuickLaunch() { | 444 | void MainWindow::slotQuickLaunch() { |
447 | 445 | ||
448 | Profile prof = manager()->profile( "default" ); | 446 | Profile prof = manager()->profile( "default" ); |
449 | if ( prof.name() == "default" ) { | 447 | if ( prof.name() == "default" ) { |
450 | create( prof ); | 448 | create( prof ); |
451 | } else { | 449 | } else { |
452 | #ifndef EAST | 450 | #ifndef EAST |
453 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); | 451 | Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 ); |
454 | newProf.setAutoConnect( true ); | 452 | newProf.setAutoConnect( true ); |
455 | create( newProf ); | 453 | create( newProf ); |
456 | slotSaveSession(); | 454 | slotSaveSession(); |
457 | #endif | 455 | #endif |
458 | } | 456 | } |
459 | } | 457 | } |
460 | 458 | ||
461 | void MainWindow::slotConfigure() { | 459 | void MainWindow::slotConfigure() { |
462 | ConfigDialog conf( manager()->all(), factory() ); | 460 | ConfigDialog conf( manager()->all(), factory() ); |
463 | 461 | ||
464 | int ret = QPEApplication::execDialog( &conf ); | 462 | int ret = QPEApplication::execDialog( &conf ); |
465 | 463 | ||
466 | if ( QDialog::Accepted == ret ) { | 464 | if ( QDialog::Accepted == ret ) { |
467 | manager()->setProfiles( conf.list() ); | 465 | manager()->setProfiles( conf.list() ); |
468 | manager()->save(); | 466 | manager()->save(); |
469 | populateProfiles(); | 467 | populateProfiles(); |
470 | } | 468 | } |
471 | } | 469 | } |
472 | /* | 470 | /* |
473 | * we will remove | 471 | * we will remove |
474 | * this window from the tabwidget | 472 | * this window from the tabwidget |
475 | * remove it from the list | 473 | * remove it from the list |
476 | * delete it | 474 | * delete it |
477 | * and set the currentSession() | 475 | * and set the currentSession() |
478 | */ | 476 | */ |
479 | void MainWindow::slotClose() { | 477 | void MainWindow::slotClose() { |
480 | if (!currentSession() ) | 478 | if (!currentSession() ) |
481 | return; | 479 | return; |
482 | 480 | ||
483 | Session* ses = currentSession(); | 481 | Session* ses = currentSession(); |
484 | owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl; | ||
485 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 482 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
486 | m_curSession = NULL; | 483 | m_curSession = NULL; |
487 | tabWidget()->remove( /*currentSession()*/ses ); | 484 | tabWidget()->remove( /*currentSession()*/ses ); |
488 | /*it's autodelete */ | 485 | /*it's autodelete */ |
489 | m_sessions.remove( ses ); | 486 | m_sessions.remove( ses ); |
490 | owarn << "after remove!!" << oendl; | ||
491 | 487 | ||
492 | if (!currentSession() ) { | 488 | if (!currentSession() ) { |
493 | m_connect->setEnabled( false ); | 489 | m_connect->setEnabled( false ); |
494 | m_disconnect->setEnabled( false ); | 490 | m_disconnect->setEnabled( false ); |
495 | m_terminate->setEnabled( false ); | 491 | m_terminate->setEnabled( false ); |
496 | m_transfer->setEnabled( false ); | 492 | m_transfer->setEnabled( false ); |
497 | m_recordScript->setEnabled( false ); | 493 | m_recordScript->setEnabled( false ); |
498 | m_saveScript->setEnabled( false ); | 494 | m_saveScript->setEnabled( false ); |
499 | m_scripts->setItemEnabled(m_runScript_id, false); | 495 | m_scripts->setItemEnabled(m_runScript_id, false); |
500 | m_fullscreen->setEnabled( false ); | 496 | m_fullscreen->setEnabled( false ); |
501 | m_wrap->setEnabled( false ); | 497 | m_wrap->setEnabled( false ); |
502 | m_closewindow->setEnabled( false ); | 498 | m_closewindow->setEnabled( false ); |
503 | } | 499 | } |
504 | 500 | ||
505 | m_kb->loadDefaults(); | 501 | m_kb->loadDefaults(); |
506 | } | 502 | } |
507 | 503 | ||
508 | /* | 504 | /* |
509 | * We will get the name | 505 | * We will get the name |
510 | * Then the profile | 506 | * Then the profile |
511 | * and then we will make a profile | 507 | * and then we will make a profile |
512 | */ | 508 | */ |
513 | void MainWindow::slotProfile( int id) { | 509 | void MainWindow::slotProfile( int id) { |
514 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 510 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
515 | create( prof ); | 511 | create( prof ); |
516 | } | 512 | } |
517 | 513 | ||
518 | 514 | ||
519 | 515 | ||
520 | void MainWindow::create( const Profile& prof ) { | 516 | void MainWindow::create( const Profile& prof ) { |
521 | if(m_curSession) | 517 | if(m_curSession) |
522 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 518 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
523 | 519 | ||
524 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 520 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
525 | 521 | ||
526 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 522 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
527 | { | 523 | { |
528 | QMessageBox::warning(this, | 524 | QMessageBox::warning(this, |
529 | QObject::tr("Session failed"), | 525 | QObject::tr("Session failed"), |
530 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 526 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
531 | //if(ses) delete ses; | 527 | //if(ses) delete ses; |
532 | return; | 528 | return; |
533 | } | 529 | } |
534 | 530 | ||
535 | m_sessions.append( ses ); | 531 | m_sessions.append( ses ); |
536 | tabWidget()->add( ses ); | 532 | tabWidget()->add( ses ); |
537 | tabWidget()->repaint(); | 533 | tabWidget()->repaint(); |
538 | m_curSession = ses; | 534 | m_curSession = ses; |
539 | 535 | ||
540 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 536 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
541 | m_connect->setEnabled( true ); | 537 | m_connect->setEnabled( true ); |
542 | m_disconnect->setEnabled( false ); | 538 | m_disconnect->setEnabled( false ); |
543 | m_terminate->setEnabled( true ); | 539 | m_terminate->setEnabled( true ); |
544 | m_fullscreen->setEnabled( true ); | 540 | m_fullscreen->setEnabled( true ); |
545 | m_wrap->setEnabled( true ); | 541 | m_wrap->setEnabled( true ); |
546 | m_closewindow->setEnabled( true ); | 542 | m_closewindow->setEnabled( true ); |
547 | m_transfer->setEnabled( false ); | 543 | m_transfer->setEnabled( false ); |
548 | m_recordScript->setEnabled( false ); | 544 | m_recordScript->setEnabled( false ); |
549 | m_saveScript->setEnabled( false ); | 545 | m_saveScript->setEnabled( false ); |
550 | m_scripts->setItemEnabled(m_runScript_id, false); | 546 | m_scripts->setItemEnabled(m_runScript_id, false); |
551 | 547 | ||
552 | // is io_layer wants direct connection, then autoconnect | 548 | // is io_layer wants direct connection, then autoconnect |
553 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { | 549 | //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { |
554 | if (prof.autoConnect()) { | 550 | if (prof.autoConnect()) { |
555 | slotConnect(); | 551 | slotConnect(); |
556 | } | 552 | } |
557 | 553 | ||
558 | QWidget *w = currentSession()->widget(); | 554 | QWidget *w = currentSession()->widget(); |
559 | if(w) w->setFocus(); | 555 | if(w) w->setFocus(); |
560 | 556 | ||
561 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 557 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
562 | m_isWrapped = true; | 558 | m_isWrapped = true; |
563 | } else { | 559 | } else { |
564 | m_isWrapped = false; | 560 | m_isWrapped = false; |
565 | } | 561 | } |
566 | 562 | ||
567 | m_kb->load(currentSession()->profile()); | 563 | m_kb->load(currentSession()->profile()); |
568 | } | 564 | } |
569 | 565 | ||
570 | void MainWindow::slotTransfer() | 566 | void MainWindow::slotTransfer() |
571 | { | 567 | { |
572 | if ( currentSession() ) { | 568 | if ( currentSession() ) { |
573 | Session *mysession = currentSession(); | 569 | Session *mysession = currentSession(); |
574 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); | 570 | TransferDialog dlg(/*mysession->widgetStack()*/this, this); |
575 | mysession->setTransferDialog(&dlg); | 571 | mysession->setTransferDialog(&dlg); |
576 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); | 572 | //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); |
577 | //dlg.showMaximized(); | 573 | //dlg.showMaximized(); |
578 | currentSession()->widgetStack()->addWidget(&dlg, -1); | 574 | currentSession()->widgetStack()->addWidget(&dlg, -1); |
579 | dlg.show(); | 575 | dlg.show(); |
580 | //dlg.exec(); | 576 | //dlg.exec(); |
581 | while(dlg.isRunning()) qApp->processEvents(); | 577 | while(dlg.isRunning()) qApp->processEvents(); |
582 | mysession->setTransferDialog(0l); | 578 | mysession->setTransferDialog(0l); |
583 | } | 579 | } |
584 | } | 580 | } |
585 | 581 | ||
586 | 582 | ||
587 | void MainWindow::slotOpenKeb(bool state) { | 583 | void MainWindow::slotOpenKeb(bool state) { |
588 | 584 | ||
589 | if (state) m_keyBar->show(); | 585 | if (state) m_keyBar->show(); |
590 | else m_keyBar->hide(); | 586 | else m_keyBar->hide(); |
591 | 587 | ||
592 | } | 588 | } |
593 | 589 | ||
594 | 590 | ||
595 | void MainWindow::slotOpenButtons( bool state ) { | 591 | void MainWindow::slotOpenButtons( bool state ) { |
596 | 592 | ||
597 | if ( state ) { | 593 | if ( state ) { |
598 | m_buttonBar->show(); | 594 | m_buttonBar->show(); |
599 | } else { | 595 | } else { |
600 | m_buttonBar->hide(); | 596 | m_buttonBar->hide(); |
601 | } | 597 | } |
602 | } | 598 | } |
603 | 599 | ||
604 | 600 | ||
605 | 601 | ||
606 | void MainWindow::slotSessionChanged( Session* ses ) { | 602 | void MainWindow::slotSessionChanged( Session* ses ) { |
607 | owarn << "changed!" << oendl; | ||
608 | |||
609 | if(m_curSession) | 603 | if(m_curSession) |
610 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); | 604 | if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); |
611 | if(ses) | 605 | if(ses) |
612 | if(ses->transferDialog()) ses->transferDialog()->show(); | 606 | if(ses->transferDialog()) ses->transferDialog()->show(); |
613 | 607 | ||
614 | if ( ses ) { | 608 | if ( ses ) { |
615 | m_curSession = ses; | 609 | m_curSession = ses; |
616 | odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl; | ||
617 | if ( m_curSession->layer()->isConnected() ) { | 610 | if ( m_curSession->layer()->isConnected() ) { |
618 | m_connect->setEnabled( false ); | 611 | m_connect->setEnabled( false ); |
619 | m_disconnect->setEnabled( true ); | 612 | m_disconnect->setEnabled( true ); |
620 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); | 613 | m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); |
621 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); | 614 | m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); |
622 | m_scripts->setItemEnabled(m_runScript_id, true); | 615 | m_scripts->setItemEnabled(m_runScript_id, true); |
623 | } else { | 616 | } else { |
624 | m_connect->setEnabled( true ); | 617 | m_connect->setEnabled( true ); |
625 | m_disconnect->setEnabled( false ); | 618 | m_disconnect->setEnabled( false ); |
626 | m_recordScript->setEnabled( false ); | 619 | m_recordScript->setEnabled( false ); |
627 | m_saveScript->setEnabled( false ); | 620 | m_saveScript->setEnabled( false ); |
628 | m_scripts->setItemEnabled(m_runScript_id, false); | 621 | m_scripts->setItemEnabled(m_runScript_id, false); |
629 | } | 622 | } |
630 | 623 | ||
631 | if ( ( currentSession()->emulationHandler()->isLogging() ) ) { | 624 | if ( ( currentSession()->emulationHandler()->isLogging() ) ) { |
632 | m_recordLog->setText( tr("Stop log") ); | 625 | m_recordLog->setText( tr("Stop log") ); |
633 | } else { | 626 | } else { |
634 | m_recordLog->setText( tr("Start log") ); | 627 | m_recordLog->setText( tr("Start log") ); |
635 | } | 628 | } |
636 | 629 | ||
637 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { | 630 | if ( ( m_curSession->layer() )->supports()[1] == 0 ) { |
638 | m_transfer->setEnabled( false ); | 631 | m_transfer->setEnabled( false ); |
639 | } else { | 632 | } else { |
640 | m_transfer->setEnabled( true ); | 633 | m_transfer->setEnabled( true ); |
641 | } | 634 | } |
642 | 635 | ||
643 | QWidget *w = m_curSession->widget(); | 636 | QWidget *w = m_curSession->widget(); |
644 | if(w) w->setFocus(); | 637 | if(w) w->setFocus(); |
645 | 638 | ||
646 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ | 639 | if(currentSession()->profile().readNumEntry("Wrap", 80)){ |
647 | m_isWrapped = true; | 640 | m_isWrapped = true; |
648 | } else { | 641 | } else { |
649 | m_isWrapped = false; | 642 | m_isWrapped = false; |
650 | } | 643 | } |
651 | 644 | ||
652 | m_kb->load(currentSession()->profile()); | 645 | m_kb->load(currentSession()->profile()); |
653 | } | 646 | } |
654 | } | 647 | } |
655 | 648 | ||
656 | void MainWindow::slotWrap() | 649 | void MainWindow::slotWrap() |
657 | { | 650 | { |
658 | if(m_curSession) | 651 | if(m_curSession) |
659 | { | 652 | { |
660 | EmulationHandler *e = m_curSession->emulationHandler(); | 653 | EmulationHandler *e = m_curSession->emulationHandler(); |
661 | if(e) | 654 | if(e) |
662 | { | 655 | { |
663 | e->setWrap( m_isWrapped ? 80:0 ); | 656 | e->setWrap( m_isWrapped ? 80:0 ); |
664 | m_isWrapped = !m_isWrapped; | 657 | m_isWrapped = !m_isWrapped; |
665 | } | 658 | } |
666 | } | 659 | } |
667 | } | 660 | } |
668 | 661 | ||
669 | void MainWindow::slotFullscreen() { | 662 | void MainWindow::slotFullscreen() { |
670 | 663 | ||
671 | 664 | ||
672 | 665 | ||
673 | if ( m_isFullscreen ) { | 666 | if ( m_isFullscreen ) { |
674 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); | 667 | ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); |
675 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); | 668 | ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); |
676 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 669 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
677 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 670 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
678 | 671 | ||
679 | } else { | 672 | } else { |
680 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); | 673 | savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); |
681 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 674 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
682 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 675 | ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
683 | , QPoint(0,0), false ); | 676 | , QPoint(0,0), false ); |
684 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 677 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
685 | ( m_curSession->widgetStack() )->setFocus(); | 678 | ( m_curSession->widgetStack() )->setFocus(); |
686 | ( m_curSession->widgetStack() )->show(); | 679 | ( m_curSession->widgetStack() )->show(); |
687 | 680 | ||
688 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 681 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
689 | 682 | ||
690 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 683 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
691 | } | 684 | } |
692 | 685 | ||
693 | m_isFullscreen = !m_isFullscreen; | 686 | m_isFullscreen = !m_isFullscreen; |
694 | } | 687 | } |
695 | 688 | ||
696 | 689 | ||
697 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { | 690 | void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { |
698 | 691 | ||
699 | if ( m_curSession ) { | 692 | if ( m_curSession ) { |
700 | 693 | ||
701 | QEvent::Type state; | 694 | QEvent::Type state; |
702 | 695 | ||
703 | if (pressed) state = QEvent::KeyPress; | 696 | if (pressed) state = QEvent::KeyPress; |
704 | else state = QEvent::KeyRelease; | 697 | else state = QEvent::KeyRelease; |
705 | 698 | ||
706 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); | 699 | QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); |
707 | 700 | ||
708 | // is this the best way to do this? cant figure out any other way to work | 701 | // is this the best way to do this? cant figure out any other way to work |
709 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 702 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
710 | ke.ignore(); | 703 | ke.ignore(); |
711 | } | 704 | } |
712 | } | 705 | } |
713 | void MainWindow::slotCopy() { | 706 | void MainWindow::slotCopy() { |
714 | if (!currentSession() ) return; | 707 | if (!currentSession() ) return; |
715 | currentSession()->emulationHandler()->copy(); | 708 | currentSession()->emulationHandler()->copy(); |
716 | } | 709 | } |
717 | void MainWindow::slotPaste() { | 710 | void MainWindow::slotPaste() { |
718 | if (!currentSession() ) return; | 711 | if (!currentSession() ) return; |
719 | currentSession()->emulationHandler()->paste(); | 712 | currentSession()->emulationHandler()->paste(); |
720 | } | 713 | } |
721 | 714 | ||
722 | /* | 715 | /* |
723 | * Save the session | 716 | * Save the session |
724 | */ | 717 | */ |
725 | 718 | ||
726 | void MainWindow::slotSaveSession() { | 719 | void MainWindow::slotSaveSession() { |
727 | if (!currentSession() ) { | 720 | if (!currentSession() ) { |
728 | QMessageBox::information(this, tr("Save Connection"), | 721 | QMessageBox::information(this, tr("Save Connection"), |
729 | tr("<qt>There is no Connection.</qt>"), 1 ); | 722 | tr("<qt>There is no Connection.</qt>"), 1 ); |
730 | return; | 723 | return; |
731 | } | 724 | } |
732 | manager()->add( currentSession()->profile() ); | 725 | manager()->add( currentSession()->profile() ); |
733 | manager()->save(); | 726 | manager()->save(); |
734 | populateProfiles(); | 727 | populateProfiles(); |
735 | } | 728 | } |
736 | 729 | ||
737 | 730 | ||
738 | 731 | ||
739 | void MainWindow::slotSaveLog() { | 732 | void MainWindow::slotSaveLog() { |
740 | 733 | ||
741 | if( currentSession()->emulationHandler()->isLogging() ) { | 734 | if( currentSession()->emulationHandler()->isLogging() ) { |
742 | DocLnk nf; | 735 | DocLnk nf; |
743 | QString m_logName = currentSession()->emulationHandler()->logFileName(); | 736 | QString m_logName = currentSession()->emulationHandler()->logFileName(); |
744 | QFileInfo info(m_logName); | 737 | QFileInfo info(m_logName); |
745 | nf.setType("text/plain"); | 738 | nf.setType("text/plain"); |
746 | nf.setFile(m_logName); | 739 | nf.setFile(m_logName); |
747 | nf.setName(info.fileName()); | 740 | nf.setName(info.fileName()); |
748 | nf.writeLink(); | 741 | nf.writeLink(); |
749 | m_recordLog->setText( tr("Start log") ); | 742 | m_recordLog->setText( tr("Start log") ); |
750 | m_recordingLog = false; | 743 | m_recordingLog = false; |
751 | currentSession()->emulationHandler()->clearLog(); | 744 | currentSession()->emulationHandler()->clearLog(); |
752 | } else { | 745 | } else { |
753 | QMap<QString, QStringList> map; | 746 | QMap<QString, QStringList> map; |
754 | QStringList text; | 747 | QStringList text; |
755 | text << "text/plain"; | 748 | text << "text/plain"; |
756 | map.insert(tr("Log"), text ); | 749 | map.insert(tr("Log"), text ); |
757 | QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 750 | QString m_logName = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
758 | if (m_logName.isEmpty() ) return; | 751 | if (m_logName.isEmpty() ) return; |
759 | 752 | ||
760 | m_recordLog->setText( tr("Stop log") ); | 753 | m_recordLog->setText( tr("Stop log") ); |
761 | m_recordingLog = true; | 754 | m_recordingLog = true; |
762 | currentSession()->emulationHandler()->startLogging(m_logName); | 755 | currentSession()->emulationHandler()->startLogging(m_logName); |
763 | } | 756 | } |
764 | } | 757 | } |
765 | 758 | ||
766 | void MainWindow::slotSaveHistory() { | 759 | void MainWindow::slotSaveHistory() { |
767 | QMap<QString, QStringList> map; | 760 | QMap<QString, QStringList> map; |
768 | QStringList text; | 761 | QStringList text; |
769 | text << "text/plain"; | 762 | text << "text/plain"; |
770 | map.insert(tr("History"), text ); | 763 | map.insert(tr("History"), text ); |
771 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); | 764 | QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); |
772 | if (filename.isEmpty() ) return; | 765 | if (filename.isEmpty() ) return; |
773 | 766 | ||
774 | QFileInfo info(filename); | 767 | QFileInfo info(filename); |
775 | 768 | ||
776 | DocLnk nf; | 769 | DocLnk nf; |
777 | nf.setType("text/plain"); | 770 | nf.setType("text/plain"); |
778 | nf.setFile(filename); | 771 | nf.setFile(filename); |
779 | nf.setName(info.fileName()); | 772 | nf.setName(info.fileName()); |
780 | 773 | ||
781 | 774 | ||
782 | QFile file(filename); | 775 | QFile file(filename); |
783 | file.open(IO_WriteOnly ); | 776 | file.open(IO_WriteOnly ); |
784 | QTextStream str(&file ); | 777 | QTextStream str(&file ); |
785 | if ( currentSession() ) | 778 | if ( currentSession() ) |
786 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); | 779 | currentSession()->emulationHandler()->emulation()->streamHistory(&str); |
787 | 780 | ||
788 | file.close(); | 781 | file.close(); |
789 | nf.writeLink(); | 782 | nf.writeLink(); |
790 | } | 783 | } |
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index b2f5c68..eb4bd0d 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,276 +1,261 @@ | |||
1 | #include "modemconfigwidget.h" | 1 | #include "modemconfigwidget.h" |
2 | #include "dialdialog.h" | 2 | #include "dialdialog.h" |
3 | #include "comboboxhelper.h" | ||
3 | 4 | ||
4 | /* OPIE */ | 5 | /* OPIE */ |
5 | #include <opie2/odebug.h> | ||
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | using namespace Opie::Core; | ||
8 | 7 | ||
9 | /* QT */ | 8 | /* QT */ |
10 | #include <qlabel.h> | 9 | #include <qlabel.h> |
11 | #include <qlayout.h> | 10 | #include <qlayout.h> |
12 | #include <qcombobox.h> | 11 | #include <qcombobox.h> |
13 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
14 | #include <qhbox.h> | 13 | #include <qhbox.h> |
15 | 14 | ||
16 | namespace { | ||
17 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
18 | uint b = bo->count(); | ||
19 | for (int i = 0; i < bo->count(); i++ ) { | ||
20 | if ( bo->text(i) == str ) { | ||
21 | bo->setCurrentItem( i ); | ||
22 | return; | ||
23 | } | ||
24 | } | ||
25 | bo->insertItem( str ); | ||
26 | bo->setCurrentItem( b ); | ||
27 | } | ||
28 | } | ||
29 | 15 | ||
30 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, | 16 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
31 | const char* na ) | 17 | const char* na ) |
32 | : ProfileDialogConnectionWidget( name, parent, na ) { | 18 | : ProfileDialogConnectionWidget( name, parent, na ) { |
33 | 19 | ||
34 | m_lay = new QVBoxLayout( this ); | 20 | m_lay = new QVBoxLayout( this ); |
35 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); | 21 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
36 | m_deviceCmb = new QComboBox(this ); | 22 | m_deviceCmb = new QComboBox(this ); |
37 | m_deviceCmb->setEditable( TRUE ); | 23 | m_deviceCmb->setEditable( TRUE ); |
38 | 24 | ||
39 | QLabel* telLabel = new QLabel( this ); | 25 | QLabel* telLabel = new QLabel( this ); |
40 | telLabel->setText( tr( "Enter telefon number here:" ) ); | 26 | telLabel->setText( tr( "Enter telefon number here:" ) ); |
41 | QHBox *buttonBox = new QHBox( this ); | 27 | QHBox *buttonBox = new QHBox( this ); |
42 | m_telNumber = new QLineEdit( buttonBox ); | 28 | m_telNumber = new QLineEdit( buttonBox ); |
43 | QPushButton *atButton = new QPushButton( buttonBox ); | 29 | QPushButton *atButton = new QPushButton( buttonBox ); |
44 | atButton->setText( tr( "AT commands" ) ); | 30 | atButton->setText( tr( "AT commands" ) ); |
45 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); | 31 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); |
46 | 32 | ||
47 | QPushButton *dialButton = new QPushButton( buttonBox ); | 33 | QPushButton *dialButton = new QPushButton( buttonBox ); |
48 | dialButton->setText( tr( "Enter number" ) ); | 34 | dialButton->setText( tr( "Enter number" ) ); |
49 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); | 35 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); |
50 | 36 | ||
51 | m_base = new IOLayerBase( this, "base" ); | 37 | m_base = new IOLayerBase( this, "base" ); |
52 | 38 | ||
53 | m_lay->addWidget( m_device ); | 39 | m_lay->addWidget( m_device ); |
54 | m_lay->addWidget( m_deviceCmb ); | 40 | m_lay->addWidget( m_deviceCmb ); |
55 | m_lay->addWidget( telLabel ); | 41 | m_lay->addWidget( telLabel ); |
56 | m_lay->addWidget( buttonBox ); | 42 | m_lay->addWidget( buttonBox ); |
57 | m_lay->addWidget( m_base ); | 43 | m_lay->addWidget( m_base ); |
58 | m_lay->addStretch( 0 ); | 44 | m_lay->addStretch( 0 ); |
59 | 45 | ||
60 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 46 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
61 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 47 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
62 | m_deviceCmb->insertItem( "/dev/ttyS2" ); | 48 | m_deviceCmb->insertItem( "/dev/ttyS2" ); |
63 | 49 | ||
64 | atConf = new ATConfigDialog( this, "ATConfig", true ); | 50 | atConf = new ATConfigDialog( this, "ATConfig", true ); |
65 | } | 51 | } |
66 | 52 | ||
67 | ModemConfigWidget::~ModemConfigWidget() { | 53 | ModemConfigWidget::~ModemConfigWidget() { |
68 | 54 | ||
69 | } | 55 | } |
70 | void ModemConfigWidget::load( const Profile& prof ) { | 56 | void ModemConfigWidget::load( const Profile& prof ) { |
71 | 57 | ||
72 | int rad_flow = prof.readNumEntry( "Flow" ); | 58 | int rad_flow = prof.readNumEntry( "Flow" ); |
73 | int rad_parity = prof.readNumEntry( "Parity" ); | 59 | int rad_parity = prof.readNumEntry( "Parity" ); |
74 | int speed = prof.readNumEntry( "Speed" ); | 60 | int speed = prof.readNumEntry( "Speed" ); |
75 | int dbits = prof.readNumEntry("DataBits"); | 61 | int dbits = prof.readNumEntry("DataBits"); |
76 | int sbits = prof.readNumEntry("StopBits"); | 62 | int sbits = prof.readNumEntry("StopBits"); |
77 | QString number = prof.readEntry( "Number" ); | 63 | QString number = prof.readEntry( "Number" ); |
78 | 64 | ||
79 | if ( !number.isEmpty() ) { | 65 | if ( !number.isEmpty() ) { |
80 | m_telNumber->setText( number ); | 66 | m_telNumber->setText( number ); |
81 | } | 67 | } |
82 | 68 | ||
83 | if ( rad_flow == 1 ) { | 69 | if ( rad_flow == 1 ) { |
84 | m_base->setFlow( IOLayerBase::Hardware ); | 70 | m_base->setFlow( IOLayerBase::Hardware ); |
85 | } else if (rad_flow == 2) { | 71 | } else if (rad_flow == 2) { |
86 | m_base->setFlow( IOLayerBase::Software ); | 72 | m_base->setFlow( IOLayerBase::Software ); |
87 | } else if (rad_flow == 0) { | 73 | } else if (rad_flow == 0) { |
88 | m_base->setFlow( IOLayerBase::None ); | 74 | m_base->setFlow( IOLayerBase::None ); |
89 | } | 75 | } |
90 | 76 | ||
91 | 77 | ||
92 | if ( rad_parity == 1 ) { | 78 | if ( rad_parity == 1 ) { |
93 | m_base->setParity( IOLayerBase::Even ); | 79 | m_base->setParity( IOLayerBase::Even ); |
94 | } else if ( rad_parity == 2 ){ | 80 | } else if ( rad_parity == 2 ){ |
95 | m_base->setParity( IOLayerBase::Odd ); | 81 | m_base->setParity( IOLayerBase::Odd ); |
96 | } else { | 82 | } else { |
97 | m_base->setParity( IOLayerBase::NonePar ); | 83 | m_base->setParity( IOLayerBase::NonePar ); |
98 | } | 84 | } |
99 | 85 | ||
100 | switch( speed ) { | 86 | switch( speed ) { |
101 | case 115200: | 87 | case 115200: |
102 | m_base->setSpeed( IOLayerBase::Baud_115200 ); | 88 | m_base->setSpeed( IOLayerBase::Baud_115200 ); |
103 | break; | 89 | break; |
104 | case 57600: | 90 | case 57600: |
105 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 91 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
106 | break; | 92 | break; |
107 | case 38400: | 93 | case 38400: |
108 | m_base->setSpeed( IOLayerBase::Baud_38400 ); | 94 | m_base->setSpeed( IOLayerBase::Baud_38400 ); |
109 | break; | 95 | break; |
110 | case 19200: | 96 | case 19200: |
111 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 97 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
112 | break; | 98 | break; |
113 | case 4800: | 99 | case 4800: |
114 | m_base->setSpeed( IOLayerBase::Baud_4800 ); | 100 | m_base->setSpeed( IOLayerBase::Baud_4800 ); |
115 | break; | 101 | break; |
116 | case 2400: | 102 | case 2400: |
117 | m_base->setSpeed( IOLayerBase::Baud_2400 ); | 103 | m_base->setSpeed( IOLayerBase::Baud_2400 ); |
118 | break; | 104 | break; |
119 | case 1200: | 105 | case 1200: |
120 | m_base->setSpeed( IOLayerBase::Baud_1200 ); | 106 | m_base->setSpeed( IOLayerBase::Baud_1200 ); |
121 | case 9600: | 107 | case 9600: |
122 | default: | 108 | default: |
123 | m_base->setSpeed( IOLayerBase::Baud_9600 ); | 109 | m_base->setSpeed( IOLayerBase::Baud_9600 ); |
124 | break; | 110 | break; |
125 | } | 111 | } |
126 | 112 | ||
127 | 113 | ||
128 | if ( dbits == 5) { | 114 | if ( dbits == 5) { |
129 | m_base->setData( IOLayerBase::Data_Five ); | 115 | m_base->setData( IOLayerBase::Data_Five ); |
130 | } else if (rad_flow == 6) { | 116 | } else if (rad_flow == 6) { |
131 | m_base->setData( IOLayerBase::Data_Six ); | 117 | m_base->setData( IOLayerBase::Data_Six ); |
132 | } else if (rad_flow == 7) { | 118 | } else if (rad_flow == 7) { |
133 | m_base->setData( IOLayerBase::Data_Seven ); | 119 | m_base->setData( IOLayerBase::Data_Seven ); |
134 | } else { | 120 | } else { |
135 | m_base->setData( IOLayerBase::Data_Eight ); | 121 | m_base->setData( IOLayerBase::Data_Eight ); |
136 | } | 122 | } |
137 | 123 | ||
138 | if ( sbits == 2) { | 124 | if ( sbits == 2) { |
139 | m_base->setStop( IOLayerBase::Stop_Two ); | 125 | m_base->setStop( IOLayerBase::Stop_Two ); |
140 | } else if ( sbits == 15 ) { | 126 | } else if ( sbits == 15 ) { |
141 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); | 127 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); |
142 | } else { | 128 | } else { |
143 | m_base->setStop( IOLayerBase::Stop_One ); | 129 | m_base->setStop( IOLayerBase::Stop_One ); |
144 | } | 130 | } |
145 | 131 | ||
146 | 132 | ||
147 | atConf->readConfig( prof ); | 133 | atConf->readConfig( prof ); |
148 | if ( prof.readEntry( "Device" ).isEmpty() ) { | 134 | if ( prof.readEntry( "Device" ).isEmpty() ) { |
149 | owarn << "device empty!" << oendl; | ||
150 | return; | 135 | return; |
151 | } | 136 | } |
152 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); | 137 | ComboboxHelper::setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); |
153 | 138 | ||
154 | 139 | ||
155 | } | 140 | } |
156 | 141 | ||
157 | /* | 142 | /* |
158 | * save speed, | 143 | * save speed, |
159 | * flow, | 144 | * flow, |
160 | * parity | 145 | * parity |
161 | */ | 146 | */ |
162 | void ModemConfigWidget::save( Profile& prof ) { | 147 | void ModemConfigWidget::save( Profile& prof ) { |
163 | int flow, parity, speed, data, stop; | 148 | int flow, parity, speed, data, stop; |
164 | flow = parity = speed = data = stop = 0; | 149 | flow = parity = speed = data = stop = 0; |
165 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); | 150 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); |
166 | 151 | ||
167 | 152 | ||
168 | switch( m_base->flow() ) { | 153 | switch( m_base->flow() ) { |
169 | case IOLayerBase::None: | 154 | case IOLayerBase::None: |
170 | flow = 0; | 155 | flow = 0; |
171 | break; | 156 | break; |
172 | case IOLayerBase::Software: | 157 | case IOLayerBase::Software: |
173 | flow = 2; | 158 | flow = 2; |
174 | break; | 159 | break; |
175 | case IOLayerBase::Hardware: | 160 | case IOLayerBase::Hardware: |
176 | flow = 1; | 161 | flow = 1; |
177 | break; | 162 | break; |
178 | } | 163 | } |
179 | 164 | ||
180 | switch( m_base->parity() ) { | 165 | switch( m_base->parity() ) { |
181 | case IOLayerBase::Odd: | 166 | case IOLayerBase::Odd: |
182 | parity = 2; | 167 | parity = 2; |
183 | break; | 168 | break; |
184 | case IOLayerBase::Even: | 169 | case IOLayerBase::Even: |
185 | parity = 1; | 170 | parity = 1; |
186 | break; | 171 | break; |
187 | case IOLayerBase::NonePar: | 172 | case IOLayerBase::NonePar: |
188 | parity = 0; | 173 | parity = 0; |
189 | break; | 174 | break; |
190 | } | 175 | } |
191 | 176 | ||
192 | switch( m_base->speed() ) { | 177 | switch( m_base->speed() ) { |
193 | case IOLayerBase::Baud_115200: | 178 | case IOLayerBase::Baud_115200: |
194 | speed = 115200; | 179 | speed = 115200; |
195 | break; | 180 | break; |
196 | case IOLayerBase::Baud_57600: | 181 | case IOLayerBase::Baud_57600: |
197 | speed = 57600; | 182 | speed = 57600; |
198 | break; | 183 | break; |
199 | case IOLayerBase::Baud_38400: | 184 | case IOLayerBase::Baud_38400: |
200 | speed = 38400; | 185 | speed = 38400; |
201 | break; | 186 | break; |
202 | case IOLayerBase::Baud_19200: | 187 | case IOLayerBase::Baud_19200: |
203 | speed = 19200; | 188 | speed = 19200; |
204 | break; | 189 | break; |
205 | case IOLayerBase::Baud_9600: | 190 | case IOLayerBase::Baud_9600: |
206 | speed = 9600; | 191 | speed = 9600; |
207 | break; | 192 | break; |
208 | case IOLayerBase::Baud_4800: | 193 | case IOLayerBase::Baud_4800: |
209 | speed = 4800; | 194 | speed = 4800; |
210 | break; | 195 | break; |
211 | case IOLayerBase::Baud_2400: | 196 | case IOLayerBase::Baud_2400: |
212 | speed = 2400; | 197 | speed = 2400; |
213 | break; | 198 | break; |
214 | case IOLayerBase::Baud_1200: | 199 | case IOLayerBase::Baud_1200: |
215 | speed = 1200; | 200 | speed = 1200; |
216 | break; | 201 | break; |
217 | } | 202 | } |
218 | 203 | ||
219 | switch( m_base->data() ) { | 204 | switch( m_base->data() ) { |
220 | case IOLayerBase::Data_Five: | 205 | case IOLayerBase::Data_Five: |
221 | data = 5; | 206 | data = 5; |
222 | break; | 207 | break; |
223 | case IOLayerBase::Data_Six: | 208 | case IOLayerBase::Data_Six: |
224 | data = 6; | 209 | data = 6; |
225 | break; | 210 | break; |
226 | case IOLayerBase::Data_Seven: | 211 | case IOLayerBase::Data_Seven: |
227 | data = 7; | 212 | data = 7; |
228 | break; | 213 | break; |
229 | case IOLayerBase::Data_Eight: | 214 | case IOLayerBase::Data_Eight: |
230 | data = 8; | 215 | data = 8; |
231 | break; | 216 | break; |
232 | } | 217 | } |
233 | 218 | ||
234 | switch( m_base->stop() ) { | 219 | switch( m_base->stop() ) { |
235 | case IOLayerBase::Stop_One: | 220 | case IOLayerBase::Stop_One: |
236 | stop = 1; | 221 | stop = 1; |
237 | break; | 222 | break; |
238 | case IOLayerBase::Stop_OnePointFive: | 223 | case IOLayerBase::Stop_OnePointFive: |
239 | stop = 15; | 224 | stop = 15; |
240 | break; | 225 | break; |
241 | case IOLayerBase::Stop_Two: | 226 | case IOLayerBase::Stop_Two: |
242 | stop = 2; | 227 | stop = 2; |
243 | break; | 228 | break; |
244 | } | 229 | } |
245 | 230 | ||
246 | prof.writeEntry( "Flow", flow ); | 231 | prof.writeEntry( "Flow", flow ); |
247 | prof.writeEntry( "Parity", parity ); | 232 | prof.writeEntry( "Parity", parity ); |
248 | prof.writeEntry( "Speed", speed ); | 233 | prof.writeEntry( "Speed", speed ); |
249 | prof.writeEntry("DataBits", data); | 234 | prof.writeEntry("DataBits", data); |
250 | prof.writeEntry("StopBits", stop); | 235 | prof.writeEntry("StopBits", stop); |
251 | prof.writeEntry( "Number", m_telNumber->text() ); | 236 | prof.writeEntry( "Number", m_telNumber->text() ); |
252 | 237 | ||
253 | 238 | ||
254 | atConf->writeConfig(prof); | 239 | atConf->writeConfig(prof); |
255 | } | 240 | } |
256 | 241 | ||
257 | void ModemConfigWidget::slotAT() { | 242 | void ModemConfigWidget::slotAT() { |
258 | // ATConfigDialog conf( this, "ATConfig", true ); | 243 | // ATConfigDialog conf( this, "ATConfig", true ); |
259 | // josef/Max I know why don't you create the stuff on the stack | 244 | // josef/Max I know why don't you create the stuff on the stack |
260 | // but making it a TopLevel Dialog and ignoring | 245 | // but making it a TopLevel Dialog and ignoring |
261 | // cancel is not fun either... | 246 | // cancel is not fun either... |
262 | // what to do? FIXME!!! -zecke | 247 | // what to do? FIXME!!! -zecke |
263 | if ( QPEApplication::execDialog( atConf ) != QDialog::Accepted ) { | 248 | if ( QPEApplication::execDialog( atConf ) != QDialog::Accepted ) { |
264 | // reload old settings | 249 | // reload old settings |
265 | } | 250 | } |
266 | } | 251 | } |
267 | 252 | ||
268 | void ModemConfigWidget::slotDial() { | 253 | void ModemConfigWidget::slotDial() { |
269 | DialDialog dial( this, "DialConfig", true ); | 254 | DialDialog dial( this, "DialConfig", true ); |
270 | if(!m_telNumber->text().isEmpty()) { | 255 | if(!m_telNumber->text().isEmpty()) { |
271 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); | 256 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); |
272 | } | 257 | } |
273 | if ( QPEApplication::execDialog( &dial ) == QDialog::Accepted ) { | 258 | if ( QPEApplication::execDialog( &dial ) == QDialog::Accepted ) { |
274 | m_telNumber->setText( dial.number() ); | 259 | m_telNumber->setText( dial.number() ); |
275 | } | 260 | } |
276 | } | 261 | } |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index d947eec..a7b9d5f 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,74 +1,76 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | 3 | HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ |
4 | file_layer.h filetransfer.h \ | 4 | file_layer.h filetransfer.h \ |
5 | metafactory.h \ | 5 | metafactory.h \ |
6 | session.h \ | 6 | session.h \ |
7 | mainwindow.h \ | 7 | mainwindow.h \ |
8 | profile.h \ | 8 | profile.h \ |
9 | profileconfig.h \ | 9 | profileconfig.h \ |
10 | profilemanager.h \ | 10 | profilemanager.h \ |
11 | tabwidget.h \ | 11 | tabwidget.h \ |
12 | configdialog.h \ | 12 | configdialog.h \ |
13 | keytrans.h \ | 13 | keytrans.h \ |
14 | transferdialog.h \ | 14 | transferdialog.h \ |
15 | profiledialogwidget.h \ | 15 | profiledialogwidget.h \ |
16 | profileeditordialog.h \ | 16 | profileeditordialog.h \ |
17 | default.h \ | 17 | default.h \ |
18 | iolayerbase.h \ | 18 | iolayerbase.h \ |
19 | serialconfigwidget.h irdaconfigwidget.h \ | 19 | serialconfigwidget.h irdaconfigwidget.h \ |
20 | btconfigwidget.h modemconfigwidget.h \ | 20 | btconfigwidget.h modemconfigwidget.h \ |
21 | atconfigdialog.h dialdialog.h \ | 21 | atconfigdialog.h dialdialog.h \ |
22 | procctl.h \ | 22 | procctl.h \ |
23 | function_keyboard.h \ | 23 | function_keyboard.h \ |
24 | receive_layer.h filereceive.h \ | 24 | receive_layer.h filereceive.h \ |
25 | script.h \ | 25 | script.h \ |
26 | dialer.h logger.h \ | 26 | dialer.h logger.h \ |
27 | terminalwidget.h \ | 27 | terminalwidget.h \ |
28 | emulation_handler.h TECommon.h \ | 28 | emulation_handler.h TECommon.h \ |
29 | TEHistory.h TEScreen.h TEWidget.h \ | 29 | TEHistory.h TEScreen.h TEWidget.h \ |
30 | TEmuVt102.h TEmulation.h MyPty.h \ | 30 | TEmuVt102.h TEmulation.h MyPty.h \ |
31 | consoleconfigwidget.h fixit.h | 31 | consoleconfigwidget.h fixit.h \ |
32 | comboboxhelper.h | ||
32 | 33 | ||
33 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | 34 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ |
34 | file_layer.cpp filetransfer.cpp \ | 35 | file_layer.cpp filetransfer.cpp \ |
35 | main.cpp \ | 36 | main.cpp \ |
36 | metafactory.cpp \ | 37 | metafactory.cpp \ |
37 | session.cpp \ | 38 | session.cpp \ |
38 | mainwindow.cpp \ | 39 | mainwindow.cpp \ |
39 | profile.cpp \ | 40 | profile.cpp \ |
40 | profileconfig.cpp \ | 41 | profileconfig.cpp \ |
41 | profilemanager.cpp \ | 42 | profilemanager.cpp \ |
42 | tabwidget.cpp \ | 43 | tabwidget.cpp \ |
43 | configdialog.cpp \ | 44 | configdialog.cpp \ |
44 | keytrans.cpp \ | 45 | keytrans.cpp \ |
45 | transferdialog.cpp \ | 46 | transferdialog.cpp \ |
46 | profiledialogwidget.cpp \ | 47 | profiledialogwidget.cpp \ |
47 | profileeditordialog.cpp \ | 48 | profileeditordialog.cpp \ |
48 | iolayerbase.cpp \ | 49 | iolayerbase.cpp \ |
49 | serialconfigwidget.cpp irdaconfigwidget.cpp \ | 50 | serialconfigwidget.cpp irdaconfigwidget.cpp \ |
50 | btconfigwidget.cpp modemconfigwidget.cpp \ | 51 | btconfigwidget.cpp modemconfigwidget.cpp \ |
51 | atconfigdialog.cpp dialdialog.cpp \ | 52 | atconfigdialog.cpp dialdialog.cpp \ |
52 | default.cpp procctl.cpp \ | 53 | default.cpp procctl.cpp \ |
53 | function_keyboard.cpp \ | 54 | function_keyboard.cpp \ |
54 | receive_layer.cpp filereceive.cpp \ | 55 | receive_layer.cpp filereceive.cpp \ |
55 | script.cpp \ | 56 | script.cpp \ |
56 | dialer.cpp logger.cpp \ | 57 | dialer.cpp logger.cpp \ |
57 | terminalwidget.cpp \ | 58 | terminalwidget.cpp \ |
58 | emulation_handler.cpp TEHistory.cpp \ | 59 | emulation_handler.cpp TEHistory.cpp \ |
59 | TEScreen.cpp TEWidget.cpp \ | 60 | TEScreen.cpp TEWidget.cpp \ |
60 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ | 61 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
61 | consoleconfigwidget.cpp fixit.cpp | 62 | consoleconfigwidget.cpp fixit.cpp \ |
63 | comboboxhelper.cpp | ||
62 | 64 | ||
63 | 65 | ||
64 | DESTDIR = $(OPIEDIR)/bin/ | 66 | DESTDIR = $(OPIEDIR)/bin/ |
65 | INTERFACES = configurebase.ui editbase.ui | 67 | INTERFACES = configurebase.ui editbase.ui |
66 | INCLUDEPATH += $(OPIEDIR)/include | 68 | INCLUDEPATH += $(OPIEDIR)/include |
67 | DEPENDPATH += $(OPIEDIR)/include | 69 | DEPENDPATH += $(OPIEDIR)/include |
68 | LIBS += -lqpe -lopiecore2 -lopieui2 -lutil | 70 | LIBS += -lqpe -lopiecore2 -lopieui2 -lutil |
69 | TARGET = opie-console | 71 | TARGET = opie-console |
70 | 72 | ||
71 | DEFINES += HAVE_OPENPTY | 73 | DEFINES += HAVE_OPENPTY |
72 | #DEFINES += EAST FSCKED_DISTRI | 74 | DEFINES += EAST FSCKED_DISTRI |
73 | 75 | ||
74 | include ( $(OPIEDIR)/include.pro ) | 76 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index dc42d8b..8109070 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,242 +1,238 @@ | |||
1 | #include "profileeditordialog.h" | ||
2 | #include "metafactory.h" | ||
3 | #include "comboboxhelper.h" | ||
4 | |||
5 | |||
1 | #include <qlayout.h> | 6 | #include <qlayout.h> |
2 | #include <qlineedit.h> | 7 | #include <qlineedit.h> |
3 | #include <qlabel.h> | 8 | #include <qlabel.h> |
4 | #include <qmessagebox.h> | 9 | #include <qmessagebox.h> |
5 | #include <qcombobox.h> | 10 | #include <qcombobox.h> |
6 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
7 | #include <qscrollview.h> | 12 | #include <qscrollview.h> |
8 | 13 | ||
9 | #include "metafactory.h" | 14 | |
10 | #include "profileeditordialog.h" | ||
11 | 15 | ||
12 | using namespace Opie::Ui; | 16 | using namespace Opie::Ui; |
13 | namespace { | 17 | |
14 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
15 | for (int i = 0; i < bo->count(); i++ ) { | ||
16 | if ( bo->text(i) == str ) { | ||
17 | bo->setCurrentItem( i ); | ||
18 | } | ||
19 | } | ||
20 | }; | ||
21 | } | ||
22 | 18 | ||
23 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 19 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
24 | const Profile& prof ) | 20 | const Profile& prof ) |
25 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 21 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
26 | { | 22 | { |
27 | initUI(); | 23 | initUI(); |
28 | 24 | ||
29 | // Apply current profile | 25 | // Apply current profile |
30 | // plugin_plugin->load(profile); | 26 | // plugin_plugin->load(profile); |
31 | // ... (reset profile name line edit etc.) | 27 | // ... (reset profile name line edit etc.) |
32 | } | 28 | } |
33 | 29 | ||
34 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 30 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
35 | : QDialog(0, 0, TRUE), m_fact( fact ) | 31 | : QDialog(0, 0, TRUE), m_fact( fact ) |
36 | { | 32 | { |
37 | // Default profile | 33 | // Default profile |
38 | m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); | 34 | m_prof = Profile(tr("New Profile"), "serial", "default", Profile::Black, Profile::White, Profile::VT102); |
39 | 35 | ||
40 | initUI(); | 36 | initUI(); |
41 | 37 | ||
42 | // Apply current profile | 38 | // Apply current profile |
43 | // plugin_plugin->load(profile); | 39 | // plugin_plugin->load(profile); |
44 | } | 40 | } |
45 | 41 | ||
46 | Profile ProfileEditorDialog::profile() const | 42 | Profile ProfileEditorDialog::profile() const |
47 | { | 43 | { |
48 | return m_prof; | 44 | return m_prof; |
49 | } | 45 | } |
50 | 46 | ||
51 | void ProfileEditorDialog::initUI() | 47 | void ProfileEditorDialog::initUI() |
52 | { | 48 | { |
53 | m_con = m_term = m_key = 0l; | 49 | m_con = m_term = m_key = 0l; |
54 | 50 | ||
55 | 51 | ||
56 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 52 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
57 | tabWidget = new OTabWidget( this ); | 53 | tabWidget = new OTabWidget( this ); |
58 | tabWidget->setTabStyle(OTabWidget::TextTab); | 54 | tabWidget->setTabStyle(OTabWidget::TextTab); |
59 | mainLayout->add(tabWidget); | 55 | mainLayout->add(tabWidget); |
60 | 56 | ||
61 | /* base tabs */ | 57 | /* base tabs */ |
62 | tabprof = new QWidget(this); | 58 | tabprof = new QWidget(this); |
63 | m_tabTerm = new QWidget(this); | 59 | m_tabTerm = new QWidget(this); |
64 | m_tabCon = new QWidget(this); | 60 | m_tabCon = new QWidget(this); |
65 | m_tabKey = new QWidget(this); | 61 | m_tabKey = new QWidget(this); |
66 | 62 | ||
67 | m_svCon = new QScrollView( m_tabCon ); | 63 | m_svCon = new QScrollView( m_tabCon ); |
68 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); | 64 | m_svCon->setResizePolicy( QScrollView::AutoOneFit ); |
69 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); | 65 | //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); |
70 | m_svCon->setFrameShape( QFrame::NoFrame ); | 66 | m_svCon->setFrameShape( QFrame::NoFrame ); |
71 | m_svTerm = new QScrollView( m_tabTerm ); | 67 | m_svTerm = new QScrollView( m_tabTerm ); |
72 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); | 68 | m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); |
73 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); | 69 | //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); |
74 | m_svTerm->setFrameShape( QFrame::NoFrame ); | 70 | m_svTerm->setFrameShape( QFrame::NoFrame ); |
75 | 71 | ||
76 | /* base layout for tabs */ | 72 | /* base layout for tabs */ |
77 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | 73 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); |
78 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); | 74 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
79 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); | 75 | m_layKey = new QHBoxLayout( m_tabKey, 2 ); |
80 | 76 | ||
81 | m_layCon->addWidget( m_svCon ); | 77 | m_layCon->addWidget( m_svCon ); |
82 | m_layTerm->addWidget( m_svTerm ); | 78 | m_layTerm->addWidget( m_svTerm ); |
83 | 79 | ||
84 | // profile tab | 80 | // profile tab |
85 | 81 | ||
86 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 82 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
87 | m_name = new QLineEdit(tabprof); | 83 | m_name = new QLineEdit(tabprof); |
88 | QLabel *con = new QLabel(tr("Connection"), tabprof ); | 84 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
89 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | 85 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); |
90 | m_conCmb = new QComboBox( tabprof ); | 86 | m_conCmb = new QComboBox( tabprof ); |
91 | m_termCmb = new QComboBox( tabprof ); | 87 | m_termCmb = new QComboBox( tabprof ); |
92 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); | 88 | m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); |
93 | 89 | ||
94 | // layouting | 90 | // layouting |
95 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 91 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
96 | vbox3->add(name); | 92 | vbox3->add(name); |
97 | vbox3->add(m_name); | 93 | vbox3->add(m_name); |
98 | vbox3->add(con ); | 94 | vbox3->add(con ); |
99 | vbox3->add(m_conCmb ); | 95 | vbox3->add(m_conCmb ); |
100 | vbox3->add(term ); | 96 | vbox3->add(term ); |
101 | vbox3->add(m_termCmb ); | 97 | vbox3->add(m_termCmb ); |
102 | vbox3->add(m_autoConnect); | 98 | vbox3->add(m_autoConnect); |
103 | vbox3->addStretch(1); | 99 | vbox3->addStretch(1); |
104 | 100 | ||
105 | m_showconntab = 0; | 101 | m_showconntab = 0; |
106 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 102 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
107 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); | 103 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
108 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); | 104 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
109 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); | 105 | tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); |
110 | tabWidget->setCurrentTab( tabprof ); | 106 | tabWidget->setCurrentTab( tabprof ); |
111 | 107 | ||
112 | 108 | ||
113 | // fill the comboboxes | 109 | // fill the comboboxes |
114 | QStringList list = m_fact->connectionWidgets(); | 110 | QStringList list = m_fact->connectionWidgets(); |
115 | QStringList::Iterator it; | 111 | QStringList::Iterator it; |
116 | for (it =list.begin(); it != list.end(); ++it ) { | 112 | for (it =list.begin(); it != list.end(); ++it ) { |
117 | m_conCmb->insertItem( (*it) ); | 113 | m_conCmb->insertItem( (*it) ); |
118 | } | 114 | } |
119 | list = m_fact->terminalWidgets(); | 115 | list = m_fact->terminalWidgets(); |
120 | for (it =list.begin(); it != list.end(); ++it ) { | 116 | for (it =list.begin(); it != list.end(); ++it ) { |
121 | m_termCmb->insertItem( (*it) ); | 117 | m_termCmb->insertItem( (*it) ); |
122 | } | 118 | } |
123 | 119 | ||
124 | // load profile values | 120 | // load profile values |
125 | m_name->setText(m_prof.name()); | 121 | m_name->setText(m_prof.name()); |
126 | slotKeyActivated( "Default Keyboard" ); | 122 | slotKeyActivated( "Default Keyboard" ); |
127 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | 123 | ComboboxHelper::setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); |
128 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | 124 | ComboboxHelper::setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); |
129 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); | 125 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
130 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | 126 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); |
131 | m_autoConnect->setChecked(m_prof.autoConnect()); | 127 | m_autoConnect->setChecked(m_prof.autoConnect()); |
132 | 128 | ||
133 | 129 | ||
134 | // signal and slots | 130 | // signal and slots |
135 | connect(m_conCmb, SIGNAL(activated(const QString&) ), | 131 | connect(m_conCmb, SIGNAL(activated(const QString&) ), |
136 | this, SLOT(slotConActivated(const QString&) ) ); | 132 | this, SLOT(slotConActivated(const QString&) ) ); |
137 | connect(m_termCmb, SIGNAL(activated(const QString&) ), | 133 | connect(m_termCmb, SIGNAL(activated(const QString&) ), |
138 | this, SLOT(slotTermActivated(const QString&) ) ); | 134 | this, SLOT(slotTermActivated(const QString&) ) ); |
139 | 135 | ||
140 | } | 136 | } |
141 | 137 | ||
142 | ProfileEditorDialog::~ProfileEditorDialog() { | 138 | ProfileEditorDialog::~ProfileEditorDialog() { |
143 | 139 | ||
144 | } | 140 | } |
145 | void ProfileEditorDialog::accept() | 141 | void ProfileEditorDialog::accept() |
146 | { | 142 | { |
147 | if(profName().isEmpty()) | 143 | if(profName().isEmpty()) |
148 | { | 144 | { |
149 | QMessageBox::information(this, | 145 | QMessageBox::information(this, |
150 | QObject::tr("Invalid profile"), | 146 | QObject::tr("Invalid profile"), |
151 | QObject::tr("Please enter a profile name.")); | 147 | QObject::tr("Please enter a profile name.")); |
152 | return; | 148 | return; |
153 | } | 149 | } |
154 | // Save profile and plugin profile | 150 | // Save profile and plugin profile |
155 | //if(plugin_plugin) plugin_plugin->save(); | 151 | //if(plugin_plugin) plugin_plugin->save(); |
156 | 152 | ||
157 | // Save general values | 153 | // Save general values |
158 | m_prof.setName( profName() ); | 154 | m_prof.setName( profName() ); |
159 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); | 155 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
160 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | 156 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); |
161 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); | 157 | m_prof.setAutoConnect( m_autoConnect->isChecked() ); |
162 | 158 | ||
163 | if (m_con ) | 159 | if (m_con ) |
164 | m_con->save( m_prof ); | 160 | m_con->save( m_prof ); |
165 | if (m_term ) | 161 | if (m_term ) |
166 | m_term->save( m_prof ); | 162 | m_term->save( m_prof ); |
167 | if (m_key) | 163 | if (m_key) |
168 | m_key->save( m_prof ); | 164 | m_key->save( m_prof ); |
169 | 165 | ||
170 | QDialog::accept(); | 166 | QDialog::accept(); |
171 | } | 167 | } |
172 | 168 | ||
173 | 169 | ||
174 | QString ProfileEditorDialog::profName()const | 170 | QString ProfileEditorDialog::profName()const |
175 | { | 171 | { |
176 | return m_name->text(); | 172 | return m_name->text(); |
177 | } | 173 | } |
178 | 174 | ||
179 | QCString ProfileEditorDialog::profType()const | 175 | QCString ProfileEditorDialog::profType()const |
180 | { | 176 | { |
181 | /*QStringList w = m_fact->configWidgets(); | 177 | /*QStringList w = m_fact->configWidgets(); |
182 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 178 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
183 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 179 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
184 | */ | 180 | */ |
185 | return QCString(); | 181 | return QCString(); |
186 | } | 182 | } |
187 | /* | 183 | /* |
188 | * we need to switch the widget | 184 | * we need to switch the widget |
189 | */ | 185 | */ |
190 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | 186 | void ProfileEditorDialog::slotConActivated( const QString& str ) { |
191 | 187 | ||
192 | delete m_con; | 188 | delete m_con; |
193 | 189 | ||
194 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); | 190 | m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); |
195 | 191 | ||
196 | if ( !m_con ) { | 192 | if ( !m_con ) { |
197 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); | 193 | m_con = new NoOptions( str, m_svCon->viewport(), "name"); |
198 | } | 194 | } |
199 | 195 | ||
200 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it | 196 | // FIXME ugly hack right. Right solution would be to look into the layer and see if it |
201 | // supports auto connect and then set it as prefered | 197 | // supports auto connect and then set it as prefered |
202 | if ( m_conCmb ->currentText() == tr("Local Console") ) { | 198 | if ( m_conCmb ->currentText() == tr("Local Console") ) { |
203 | m_autoConnect->setChecked( true ); | 199 | m_autoConnect->setChecked( true ); |
204 | m_prof.writeEntry("Terminal", Profile::Linux ); | 200 | m_prof.writeEntry("Terminal", Profile::Linux ); |
205 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | 201 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); |
206 | } else { | 202 | } else { |
207 | m_prof.writeEntry("Terminal", Profile::VT102 ); | 203 | m_prof.writeEntry("Terminal", Profile::VT102 ); |
208 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); | 204 | slotTermActivated( m_fact->external (m_prof.terminalName() ) ); |
209 | m_autoConnect->setChecked( false ); | 205 | m_autoConnect->setChecked( false ); |
210 | } | 206 | } |
211 | 207 | ||
212 | m_con->load( m_prof ); | 208 | m_con->load( m_prof ); |
213 | m_svCon->addChild( m_con ); | 209 | m_svCon->addChild( m_con ); |
214 | } | 210 | } |
215 | 211 | ||
216 | 212 | ||
217 | /* | 213 | /* |
218 | * we need to switch the widget | 214 | * we need to switch the widget |
219 | */ | 215 | */ |
220 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | 216 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { |
221 | 217 | ||
222 | delete m_term; | 218 | delete m_term; |
223 | 219 | ||
224 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); | 220 | m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); |
225 | 221 | ||
226 | if ( m_term ) { | 222 | if ( m_term ) { |
227 | m_term->load( m_prof ); | 223 | m_term->load( m_prof ); |
228 | m_svTerm->addChild( m_term ); | 224 | m_svTerm->addChild( m_term ); |
229 | } | 225 | } |
230 | } | 226 | } |
231 | 227 | ||
232 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { | 228 | void ProfileEditorDialog::slotKeyActivated(const QString &str) { |
233 | delete m_key; | 229 | delete m_key; |
234 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); | 230 | m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); |
235 | 231 | ||
236 | if (m_key) { | 232 | if (m_key) { |
237 | 233 | ||
238 | m_key->load(m_prof); | 234 | m_key->load(m_prof); |
239 | m_layKey->addWidget(m_key); | 235 | m_layKey->addWidget(m_key); |
240 | } | 236 | } |
241 | 237 | ||
242 | } | 238 | } |
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index c4c9c99..4efb286 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp | |||
@@ -1,216 +1,203 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qlayout.h> | ||
3 | #include <qcombobox.h> | ||
4 | |||
5 | #include "iolayerbase.h" | 1 | #include "iolayerbase.h" |
6 | #include "serialconfigwidget.h" | 2 | #include "serialconfigwidget.h" |
3 | #include "comboboxhelper.h" | ||
7 | 4 | ||
8 | namespace { | 5 | #include <qlabel.h> |
9 | void setCurrent( const QString& str, QComboBox* bo ) { | 6 | #include <qlayout.h> |
10 | uint b = bo->count(); | 7 | #include <qcombobox.h> |
11 | for (int i = 0; i < bo->count(); i++ ) { | ||
12 | if ( bo->text(i) == str ) { | ||
13 | bo->setCurrentItem( i ); | ||
14 | return; | ||
15 | } | ||
16 | } | ||
17 | bo->insertItem( str ); | ||
18 | bo->setCurrentItem( b ); | ||
19 | } | ||
20 | 8 | ||
21 | 9 | ||
22 | } | ||
23 | 10 | ||
24 | SerialConfigWidget::SerialConfigWidget( const QString& name, | 11 | SerialConfigWidget::SerialConfigWidget( const QString& name, |
25 | QWidget* parent, | 12 | QWidget* parent, |
26 | const char* na ) | 13 | const char* na ) |
27 | : ProfileDialogConnectionWidget( name, parent, na ) { | 14 | : ProfileDialogConnectionWidget( name, parent, na ) { |
28 | 15 | ||
29 | m_lay = new QVBoxLayout(this ); | 16 | m_lay = new QVBoxLayout(this ); |
30 | m_device = new QLabel(tr("Device"), this ); | 17 | m_device = new QLabel(tr("Device"), this ); |
31 | m_deviceCmb = new QComboBox(this ); | 18 | m_deviceCmb = new QComboBox(this ); |
32 | m_deviceCmb->setEditable( TRUE ); | 19 | m_deviceCmb->setEditable( TRUE ); |
33 | 20 | ||
34 | m_base = new IOLayerBase(this, "base"); | 21 | m_base = new IOLayerBase(this, "base"); |
35 | 22 | ||
36 | m_lay->addWidget( m_device ); | 23 | m_lay->addWidget( m_device ); |
37 | m_lay->addWidget( m_deviceCmb ); | 24 | m_lay->addWidget( m_deviceCmb ); |
38 | m_lay->addWidget( m_base ); | 25 | m_lay->addWidget( m_base ); |
39 | 26 | ||
40 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 27 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
41 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 28 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
42 | m_deviceCmb->insertItem( "/dev/ttySA0"); | 29 | m_deviceCmb->insertItem( "/dev/ttySA0"); |
43 | m_deviceCmb->insertItem( "/dev/ttySA1"); | 30 | m_deviceCmb->insertItem( "/dev/ttySA1"); |
44 | 31 | ||
45 | } | 32 | } |
46 | SerialConfigWidget::~SerialConfigWidget() { | 33 | SerialConfigWidget::~SerialConfigWidget() { |
47 | 34 | ||
48 | } | 35 | } |
49 | void SerialConfigWidget::load( const Profile& prof ) { | 36 | void SerialConfigWidget::load( const Profile& prof ) { |
50 | int rad_flow = prof.readNumEntry("Flow"); | 37 | int rad_flow = prof.readNumEntry("Flow"); |
51 | int rad_parity = prof.readNumEntry("Parity"); | 38 | int rad_parity = prof.readNumEntry("Parity"); |
52 | int speed = prof.readNumEntry("Speed"); | 39 | int speed = prof.readNumEntry("Speed"); |
53 | int dbits = prof.readNumEntry("DataBits"); | 40 | int dbits = prof.readNumEntry("DataBits"); |
54 | int sbits = prof.readNumEntry("StopBits"); | 41 | int sbits = prof.readNumEntry("StopBits"); |
55 | 42 | ||
56 | if (rad_flow == 1) { | 43 | if (rad_flow == 1) { |
57 | m_base->setFlow( IOLayerBase::Hardware ); | 44 | m_base->setFlow( IOLayerBase::Hardware ); |
58 | } else if (rad_flow == 2) { | 45 | } else if (rad_flow == 2) { |
59 | m_base->setFlow( IOLayerBase::Software ); | 46 | m_base->setFlow( IOLayerBase::Software ); |
60 | } else { | 47 | } else { |
61 | m_base->setFlow( IOLayerBase::None ); | 48 | m_base->setFlow( IOLayerBase::None ); |
62 | } | 49 | } |
63 | 50 | ||
64 | if (rad_parity == 1) { | 51 | if (rad_parity == 1) { |
65 | m_base->setParity( IOLayerBase::Even ); | 52 | m_base->setParity( IOLayerBase::Even ); |
66 | } else if ( rad_parity == 2 ) { | 53 | } else if ( rad_parity == 2 ) { |
67 | m_base->setParity( IOLayerBase::Odd ); | 54 | m_base->setParity( IOLayerBase::Odd ); |
68 | } else { | 55 | } else { |
69 | m_base->setParity( IOLayerBase::NonePar ); | 56 | m_base->setParity( IOLayerBase::NonePar ); |
70 | } | 57 | } |
71 | 58 | ||
72 | switch( speed ) { | 59 | switch( speed ) { |
73 | case 115200: | 60 | case 115200: |
74 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 61 | m_base->setSpeed(IOLayerBase::Baud_115200 ); |
75 | break; | 62 | break; |
76 | case 57600: | 63 | case 57600: |
77 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 64 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
78 | break; | 65 | break; |
79 | case 38400: | 66 | case 38400: |
80 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 67 | m_base->setSpeed(IOLayerBase::Baud_38400 ); |
81 | break; | 68 | break; |
82 | case 19200: | 69 | case 19200: |
83 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 70 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
84 | break; | 71 | break; |
85 | case 4800: | 72 | case 4800: |
86 | m_base->setSpeed( IOLayerBase::Baud_4800 ); | 73 | m_base->setSpeed( IOLayerBase::Baud_4800 ); |
87 | break; | 74 | break; |
88 | case 2400: | 75 | case 2400: |
89 | m_base->setSpeed( IOLayerBase::Baud_2400 ); | 76 | m_base->setSpeed( IOLayerBase::Baud_2400 ); |
90 | break; | 77 | break; |
91 | case 1200: | 78 | case 1200: |
92 | m_base->setSpeed( IOLayerBase::Baud_1200 ); | 79 | m_base->setSpeed( IOLayerBase::Baud_1200 ); |
93 | break; | 80 | break; |
94 | case 9600: | 81 | case 9600: |
95 | default: | 82 | default: |
96 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 83 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
97 | break; | 84 | break; |
98 | } | 85 | } |
99 | 86 | ||
100 | if ( dbits == 5) { | 87 | if ( dbits == 5) { |
101 | m_base->setData( IOLayerBase::Data_Five ); | 88 | m_base->setData( IOLayerBase::Data_Five ); |
102 | } else if (rad_flow == 6) { | 89 | } else if (rad_flow == 6) { |
103 | m_base->setData( IOLayerBase::Data_Six ); | 90 | m_base->setData( IOLayerBase::Data_Six ); |
104 | } else if (rad_flow == 7) { | 91 | } else if (rad_flow == 7) { |
105 | m_base->setData( IOLayerBase::Data_Seven ); | 92 | m_base->setData( IOLayerBase::Data_Seven ); |
106 | } else { | 93 | } else { |
107 | m_base->setData( IOLayerBase::Data_Eight ); | 94 | m_base->setData( IOLayerBase::Data_Eight ); |
108 | } | 95 | } |
109 | 96 | ||
110 | if ( sbits == 2) { | 97 | if ( sbits == 2) { |
111 | m_base->setStop( IOLayerBase::Stop_Two ); | 98 | m_base->setStop( IOLayerBase::Stop_Two ); |
112 | } else if ( sbits == 15 ) { | 99 | } else if ( sbits == 15 ) { |
113 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); | 100 | m_base->setStop( IOLayerBase::Stop_OnePointFive ); |
114 | } else { | 101 | } else { |
115 | m_base->setStop( IOLayerBase::Stop_One ); | 102 | m_base->setStop( IOLayerBase::Stop_One ); |
116 | } | 103 | } |
117 | 104 | ||
118 | if ( prof.readEntry("Device").isEmpty() ) return; | 105 | if ( prof.readEntry("Device").isEmpty() ) return; |
119 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 106 | ComboboxHelper::setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
120 | 107 | ||
121 | } | 108 | } |
122 | /* | 109 | /* |
123 | * save speed, | 110 | * save speed, |
124 | * flow, | 111 | * flow, |
125 | * parity | 112 | * parity |
126 | */ | 113 | */ |
127 | void SerialConfigWidget::save( Profile& prof ) { | 114 | void SerialConfigWidget::save( Profile& prof ) { |
128 | int flow, parity, speed, data, stop; | 115 | int flow, parity, speed, data, stop; |
129 | flow = parity = speed = data = stop = 0; | 116 | flow = parity = speed = data = stop = 0; |
130 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 117 | prof.writeEntry("Device", m_deviceCmb->currentText() ); |
131 | 118 | ||
132 | switch( m_base->flow() ) { | 119 | switch( m_base->flow() ) { |
133 | case IOLayerBase::None: | 120 | case IOLayerBase::None: |
134 | flow = 0; | 121 | flow = 0; |
135 | break; | 122 | break; |
136 | case IOLayerBase::Software: | 123 | case IOLayerBase::Software: |
137 | flow = 2; | 124 | flow = 2; |
138 | break; | 125 | break; |
139 | case IOLayerBase::Hardware: | 126 | case IOLayerBase::Hardware: |
140 | flow = 1; | 127 | flow = 1; |
141 | break; | 128 | break; |
142 | } | 129 | } |
143 | 130 | ||
144 | switch( m_base->parity() ) { | 131 | switch( m_base->parity() ) { |
145 | case IOLayerBase::Odd: | 132 | case IOLayerBase::Odd: |
146 | parity = 2; | 133 | parity = 2; |
147 | break; | 134 | break; |
148 | case IOLayerBase::Even: | 135 | case IOLayerBase::Even: |
149 | parity = 1; | 136 | parity = 1; |
150 | break; | 137 | break; |
151 | case IOLayerBase::NonePar: | 138 | case IOLayerBase::NonePar: |
152 | parity = 0; | 139 | parity = 0; |
153 | break; | 140 | break; |
154 | } | 141 | } |
155 | 142 | ||
156 | switch( m_base->speed() ) { | 143 | switch( m_base->speed() ) { |
157 | case IOLayerBase::Baud_115200: | 144 | case IOLayerBase::Baud_115200: |
158 | speed = 115200; | 145 | speed = 115200; |
159 | break; | 146 | break; |
160 | case IOLayerBase::Baud_57600: | 147 | case IOLayerBase::Baud_57600: |
161 | speed = 57600; | 148 | speed = 57600; |
162 | break; | 149 | break; |
163 | case IOLayerBase::Baud_38400: | 150 | case IOLayerBase::Baud_38400: |
164 | speed = 38400; | 151 | speed = 38400; |
165 | break; | 152 | break; |
166 | case IOLayerBase::Baud_19200: | 153 | case IOLayerBase::Baud_19200: |
167 | speed = 19200; | 154 | speed = 19200; |
168 | break; | 155 | break; |
169 | case IOLayerBase::Baud_4800: | 156 | case IOLayerBase::Baud_4800: |
170 | speed = 4800; | 157 | speed = 4800; |
171 | break; | 158 | break; |
172 | case IOLayerBase::Baud_2400: | 159 | case IOLayerBase::Baud_2400: |
173 | speed = 2400; | 160 | speed = 2400; |
174 | break; | 161 | break; |
175 | case IOLayerBase::Baud_1200: | 162 | case IOLayerBase::Baud_1200: |
176 | speed = 1200; | 163 | speed = 1200; |
177 | break; | 164 | break; |
178 | default: | 165 | default: |
179 | case IOLayerBase::Baud_9600: | 166 | case IOLayerBase::Baud_9600: |
180 | speed = 9600; | 167 | speed = 9600; |
181 | break; | 168 | break; |
182 | } | 169 | } |
183 | 170 | ||
184 | switch( m_base->data() ) { | 171 | switch( m_base->data() ) { |
185 | case IOLayerBase::Data_Five: | 172 | case IOLayerBase::Data_Five: |
186 | data = 5; | 173 | data = 5; |
187 | break; | 174 | break; |
188 | case IOLayerBase::Data_Six: | 175 | case IOLayerBase::Data_Six: |
189 | data = 6; | 176 | data = 6; |
190 | break; | 177 | break; |
191 | case IOLayerBase::Data_Seven: | 178 | case IOLayerBase::Data_Seven: |
192 | data = 7; | 179 | data = 7; |
193 | break; | 180 | break; |
194 | case IOLayerBase::Data_Eight: | 181 | case IOLayerBase::Data_Eight: |
195 | data = 8; | 182 | data = 8; |
196 | break; | 183 | break; |
197 | } | 184 | } |
198 | 185 | ||
199 | switch( m_base->stop() ) { | 186 | switch( m_base->stop() ) { |
200 | case IOLayerBase::Stop_One: | 187 | case IOLayerBase::Stop_One: |
201 | stop = 1; | 188 | stop = 1; |
202 | break; | 189 | break; |
203 | case IOLayerBase::Stop_OnePointFive: | 190 | case IOLayerBase::Stop_OnePointFive: |
204 | stop = 15; | 191 | stop = 15; |
205 | break; | 192 | break; |
206 | case IOLayerBase::Stop_Two: | 193 | case IOLayerBase::Stop_Two: |
207 | stop = 2; | 194 | stop = 2; |
208 | break; | 195 | break; |
209 | } | 196 | } |
210 | 197 | ||
211 | prof.writeEntry("Flow", flow); | 198 | prof.writeEntry("Flow", flow); |
212 | prof.writeEntry("Parity", parity); | 199 | prof.writeEntry("Parity", parity); |
213 | prof.writeEntry("Speed", speed); | 200 | prof.writeEntry("Speed", speed); |
214 | prof.writeEntry("DataBits", data); | 201 | prof.writeEntry("DataBits", data); |
215 | prof.writeEntry("StopBits", stop); | 202 | prof.writeEntry("StopBits", stop); |
216 | } | 203 | } |
diff --git a/noncore/apps/opie-console/settings.ui b/noncore/apps/opie-console/settings.ui deleted file mode 100644 index 6944dd0..0000000 --- a/noncore/apps/opie-console/settings.ui +++ b/dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | <!DOCTYPE UI><UI> | ||
2 | <class>Settings</class> | ||
3 | <widget> | ||
4 | <class>QDialog</class> | ||
5 | <property stdset="1"> | ||
6 | <name>name</name> | ||
7 | <cstring>Settings</cstring> | ||
8 | </property> | ||
9 | <property stdset="1"> | ||
10 | <name>geometry</name> | ||
11 | <rect> | ||
12 | <x>0</x> | ||
13 | <y>0</y> | ||
14 | <width>596</width> | ||
15 | <height>480</height> | ||
16 | </rect> | ||
17 | </property> | ||
18 | <property stdset="1"> | ||
19 | <name>caption</name> | ||
20 | <string>Settings</string> | ||
21 | </property> | ||
22 | </widget> | ||
23 | </UI> | ||
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index f505998..3299e33 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp | |||
@@ -1,86 +1,69 @@ | |||
1 | 1 | ||
2 | #include "sz_transfer.h" | 2 | #include "sz_transfer.h" |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include <sys/termios.h> | 5 | #include <sys/termios.h> |
6 | 6 | ||
7 | 7 | ||
8 | 8 | ||
9 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
10 | using namespace Opie::Core; | 10 | using namespace Opie::Core; |
11 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) | 11 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) |
12 | { | 12 | { |
13 | } | 13 | } |
14 | 14 | ||
15 | SzTransfer::~SzTransfer() { | 15 | SzTransfer::~SzTransfer() { |
16 | } | 16 | } |
17 | 17 | ||
18 | void SzTransfer::sendFile(const QFile& file) { | 18 | void SzTransfer::sendFile(const QFile& file) { |
19 | 19 | ||
20 | sendFile(file.name()); | 20 | sendFile(file.name()); |
21 | } | 21 | } |
22 | 22 | ||
23 | void SzTransfer::sendFile(const QString& file) { | 23 | void SzTransfer::sendFile(const QString& file) { |
24 | 24 | ||
25 | //setcbreak(2); /* raw no echo */ | 25 | //setcbreak(2); /* raw no echo */ |
26 | 26 | ||
27 | proc = new OProcess; | 27 | proc = new OProcess; |
28 | *proc << "sz"; | 28 | *proc << "sz"; |
29 | *proc << "-v" << "-v" << "-b" << file; | 29 | *proc << "-v" << "-v" << "-b" << file; |
30 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), | 30 | connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), |
31 | this, SLOT(sent())); | 31 | this, SLOT(sent())); |
32 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 32 | connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
33 | this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int))); | 33 | this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int))); |
34 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 34 | connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
35 | this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); | 35 | this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); |
36 | connect(layer(), SIGNAL(received(const QByteArray&)), | 36 | connect(layer(), SIGNAL(received(const QByteArray&)), |
37 | this, SLOT(receivedStdin(const QByteArray&))); | 37 | this, SLOT(receivedStdin(const QByteArray&))); |
38 | proc->start(OProcess::NotifyOnExit, OProcess::All); | 38 | proc->start(OProcess::NotifyOnExit, OProcess::All); |
39 | 39 | ||
40 | } | 40 | } |
41 | 41 | ||
42 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { | 42 | void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { |
43 | |||
44 | owarn << "recieved from sz on stdout " << buflen << " bytes" << oendl; | ||
45 | |||
46 | QByteArray data(buflen); | 43 | QByteArray data(buflen); |
47 | data.fill(*buffer, buflen); | 44 | data.fill(*buffer, buflen); |
45 | |||
46 | #ifdef DEBUG_RECEIVE | ||
48 | for (uint i = 0; i < data.count(); i++ ) { | 47 | for (uint i = 0; i < data.count(); i++ ) { |
49 | printf("%c", buffer[i] ); | 48 | printf("%c", buffer[i] ); |
50 | } | 49 | } |
51 | printf("\n"); | 50 | printf("\n"); |
51 | #endif | ||
52 | 52 | ||
53 | // send out through the io layer | 53 | // send out through the io layer |
54 | layer()->send(data); | 54 | layer()->send(data); |
55 | } | 55 | } |
56 | 56 | ||
57 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { | 57 | void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { |
58 | |||
59 | // parse and show data in a progress dialog/widget | ||
60 | printf("stderr:\n"); | ||
61 | //for (int i = 0; i < length; i++) | ||
62 | // printf("%c", buffer[i]); | ||
63 | //printf("\n"); | ||
64 | } | 58 | } |
65 | 59 | ||
66 | void SzTransfer::receivedStdin(const QByteArray &data) { | 60 | void SzTransfer::receivedStdin(const QByteArray &data) { |
67 | |||
68 | owarn << "recieved from io_serial " << data.size() << " bytes" << oendl; | ||
69 | |||
70 | // recieved data from the io layer goes to sz | 61 | // recieved data from the io layer goes to sz |
71 | proc->writeStdin(data.data(), data.size()); | 62 | proc->writeStdin(data.data(), data.size()); |
72 | |||
73 | } | 63 | } |
74 | 64 | ||
75 | void SzTransfer::sent() { | 65 | void SzTransfer::sent() { |
76 | |||
77 | owarn << "sent file" << oendl; | ||
78 | |||
79 | //setcbreak(0); /* default */ | ||
80 | |||
81 | |||
82 | delete proc; | 66 | delete proc; |
83 | disconnect(layer(), SIGNAL(received(const QByteArray&)), | 67 | disconnect(layer(), SIGNAL(received(const QByteArray&)), |
84 | this, SLOT(receivedStdin(const QByteArray&))); | 68 | this, SLOT(receivedStdin(const QByteArray&))); |
85 | |||
86 | } | 69 | } |
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp index 152c26b..79ccac5 100644 --- a/noncore/apps/opie-console/tabwidget.cpp +++ b/noncore/apps/opie-console/tabwidget.cpp | |||
@@ -1,50 +1,46 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "tabwidget.h" | 3 | #include "tabwidget.h" |
4 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | using namespace Opie::Core; | ||
8 | using Opie::Ui::OTabWidget; | 5 | using Opie::Ui::OTabWidget; |
9 | 6 | ||
10 | TabWidget::TabWidget( QWidget* parent, const char* name ) | 7 | TabWidget::TabWidget( QWidget* parent, const char* name ) |
11 | : OTabWidget( parent, name ) { | 8 | : OTabWidget( parent, name ) { |
12 | connect(this, SIGNAL( currentChanged(QWidget*) ), | 9 | connect(this, SIGNAL( currentChanged(QWidget*) ), |
13 | this, SLOT( slotCurChanged(QWidget*) ) ); | 10 | this, SLOT( slotCurChanged(QWidget*) ) ); |
14 | } | 11 | } |
15 | 12 | ||
16 | TabWidget::~TabWidget() { | 13 | TabWidget::~TabWidget() { |
17 | } | 14 | } |
18 | 15 | ||
19 | void TabWidget::add( Session* ses ) { | 16 | void TabWidget::add( Session* ses ) { |
20 | owarn << "session ses " + ses->name() << oendl; | ||
21 | if ( !ses->widgetStack() ) return; | 17 | if ( !ses->widgetStack() ) return; |
22 | //reparent( ses->widgetStack(), QPoint() ); | 18 | //reparent( ses->widgetStack(), QPoint() ); |
23 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); | 19 | addTab( ses->widgetStack(), "console/konsole", ses->name() ); |
24 | //addTab( ses->widgetStack(), ses->name() ); | 20 | //addTab( ses->widgetStack(), ses->name() ); |
25 | m_map.insert( ses->widgetStack(), ses ); | 21 | m_map.insert( ses->widgetStack(), ses ); |
26 | } | 22 | } |
27 | 23 | ||
28 | void TabWidget::remove( Session* ses ) { | 24 | void TabWidget::remove( Session* ses ) { |
29 | m_map.remove( ses->widgetStack() ); | 25 | m_map.remove( ses->widgetStack() ); |
30 | removePage( ses->widgetStack() ); | 26 | removePage( ses->widgetStack() ); |
31 | } | 27 | } |
32 | 28 | ||
33 | void TabWidget::slotCurChanged( QWidget* wid ) { | 29 | void TabWidget::slotCurChanged( QWidget* wid ) { |
34 | QMap<QWidget*, Session*>::Iterator it; | 30 | QMap<QWidget*, Session*>::Iterator it; |
35 | it = m_map.find( wid ); | 31 | it = m_map.find( wid ); |
36 | if ( it == m_map.end() ) { | 32 | if ( it == m_map.end() ) { |
37 | return; | 33 | return; |
38 | } | 34 | } |
39 | 35 | ||
40 | emit activated( it.data() ); | 36 | emit activated( it.data() ); |
41 | } | 37 | } |
42 | void TabWidget::setCurrent( Session* ses ) { | 38 | void TabWidget::setCurrent( Session* ses ) { |
43 | if (!ses ) | 39 | if (!ses ) |
44 | return; | 40 | return; |
45 | 41 | ||
46 | //showPage( ses->widgetStack() ); | 42 | //showPage( ses->widgetStack() ); |
47 | setCurrentTab( ses->widgetStack() ); | 43 | setCurrentTab( ses->widgetStack() ); |
48 | } | 44 | } |
49 | 45 | ||
50 | 46 | ||
diff --git a/noncore/apps/opie-console/terminalwidget.cpp b/noncore/apps/opie-console/terminalwidget.cpp index 3e3b8a6..907de1b 100644 --- a/noncore/apps/opie-console/terminalwidget.cpp +++ b/noncore/apps/opie-console/terminalwidget.cpp | |||
@@ -1,242 +1,236 @@ | |||
1 | #include "terminalwidget.h" | 1 | #include "terminalwidget.h" |
2 | 2 | ||
3 | /* OPIE */ | ||
4 | #include <opie2/odebug.h> | ||
5 | |||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 3 | /* QT */ |
9 | #include <qlabel.h> | 4 | #include <qlabel.h> |
10 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
11 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
12 | #include <qradiobutton.h> | 7 | #include <qradiobutton.h> |
13 | #include <qhgroupbox.h> | 8 | #include <qhgroupbox.h> |
14 | #include <qhbuttongroup.h> | 9 | #include <qhbuttongroup.h> |
15 | #include <qlayout.h> | 10 | #include <qlayout.h> |
16 | #include <qhbox.h> | 11 | #include <qhbox.h> |
17 | 12 | ||
18 | namespace { | 13 | namespace { |
19 | enum TermIds { | 14 | enum TermIds { |
20 | id_term_vt100 = 0, | 15 | id_term_vt100 = 0, |
21 | id_term_vt102, | 16 | id_term_vt102, |
22 | id_term_linux, | 17 | id_term_linux, |
23 | id_term_xterm | 18 | id_term_xterm |
24 | }; | 19 | }; |
25 | 20 | ||
26 | enum ColourIds { | 21 | enum ColourIds { |
27 | id_term_black, | 22 | id_term_black, |
28 | id_term_white, | 23 | id_term_white, |
29 | id_term_green, | 24 | id_term_green, |
30 | id_term_orange | 25 | id_term_orange |
31 | }; | 26 | }; |
32 | 27 | ||
33 | enum FontIds { | 28 | enum FontIds { |
34 | id_size_small, | 29 | id_size_small, |
35 | id_size_medium, | 30 | id_size_medium, |
36 | id_size_large | 31 | id_size_large |
37 | }; | 32 | }; |
38 | }; | 33 | }; |
39 | 34 | ||
40 | TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, | 35 | TerminalWidget::TerminalWidget( const QString& name, QWidget* parent, |
41 | const char* na ) | 36 | const char* na ) |
42 | : ProfileDialogTerminalWidget( name, parent, na ) { | 37 | : ProfileDialogTerminalWidget( name, parent, na ) { |
43 | 38 | ||
44 | m_terminal = new QLabel(tr("Terminal Type"), this ); | 39 | m_terminal = new QLabel(tr("Terminal Type"), this ); |
45 | m_terminalBox = new QComboBox(this); | 40 | m_terminalBox = new QComboBox(this); |
46 | m_colorLabel = new QLabel(tr("Color scheme"), this); | 41 | m_colorLabel = new QLabel(tr("Color scheme"), this); |
47 | m_colorCmb = new QComboBox(this ); | 42 | m_colorCmb = new QComboBox(this ); |
48 | 43 | ||
49 | // m_groupSize = new QHButtonGroup(tr("Font size"), this ); | 44 | // m_groupSize = new QHButtonGroup(tr("Font size"), this ); |
50 | m_groupSize = new QHBox( this ); | 45 | m_groupSize = new QHBox( this ); |
51 | m_fontSelector = new Opie::Ui::OFontSelector( false, m_groupSize ); | 46 | m_fontSelector = new Opie::Ui::OFontSelector( false, m_groupSize ); |
52 | 47 | ||
53 | // m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); | 48 | // m_sizeSmall = new QRadioButton(tr("small"), m_groupSize ); |
54 | // m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); | 49 | // m_sizeMedium = new QRadioButton(tr("medium"), m_groupSize ); |
55 | // m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); | 50 | // m_sizeLarge = new QRadioButton(tr("large"), m_groupSize ); |
56 | 51 | ||
57 | m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); | 52 | m_groupConv = new QHGroupBox( tr("Line-break conversions"), this ); |
58 | m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); | 53 | m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv ); |
59 | m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); | 54 | m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv ); |
60 | 55 | ||
61 | 56 | ||
62 | m_groupOptions = new QHGroupBox( tr("Options"), this ); | 57 | m_groupOptions = new QHGroupBox( tr("Options"), this ); |
63 | m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); | 58 | m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions ); |
64 | m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); | 59 | m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions ); |
65 | 60 | ||
66 | m_lroot = new QVBoxLayout( this ); | 61 | m_lroot = new QVBoxLayout( this ); |
67 | m_typeBox = new QVBoxLayout( m_lroot ); | 62 | m_typeBox = new QVBoxLayout( m_lroot ); |
68 | m_colorBox = new QVBoxLayout( m_lroot ); | 63 | m_colorBox = new QVBoxLayout( m_lroot ); |
69 | 64 | ||
70 | // Layout | 65 | // Layout |
71 | m_typeBox->add( m_terminal ); | 66 | m_typeBox->add( m_terminal ); |
72 | m_typeBox->add( m_terminalBox ); | 67 | m_typeBox->add( m_terminalBox ); |
73 | m_lroot->add( m_groupSize ); | 68 | m_lroot->add( m_groupSize ); |
74 | 69 | ||
75 | m_colorBox->add( m_colorLabel ); | 70 | m_colorBox->add( m_colorLabel ); |
76 | m_colorBox->add( m_colorCmb ); | 71 | m_colorBox->add( m_colorCmb ); |
77 | 72 | ||
78 | m_lroot->add( m_groupConv ); | 73 | m_lroot->add( m_groupConv ); |
79 | m_lroot->add( m_groupOptions ); | 74 | m_lroot->add( m_groupOptions ); |
80 | m_lroot->addStretch( 0 ); | 75 | m_lroot->addStretch( 0 ); |
81 | 76 | ||
82 | // Fill in some options | 77 | // Fill in some options |
83 | owarn << "Options for terminal box" << oendl; | ||
84 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); | 78 | m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ ); |
85 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); | 79 | m_terminalBox->insertItem( tr("VT 102"), 1 ); // /* , id_term_vt102 */); |
86 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); | 80 | m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux ); |
87 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); | 81 | m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm ); |
88 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); | 82 | //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi ); |
89 | 83 | ||
90 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); | 84 | m_colorCmb->insertItem( tr("black on white"), id_term_black ); |
91 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); | 85 | m_colorCmb->insertItem( tr("white on black"), id_term_white ); |
92 | m_colorCmb->insertItem( tr("green on black"), id_term_green ); | 86 | m_colorCmb->insertItem( tr("green on black"), id_term_green ); |
93 | m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); | 87 | m_colorCmb->insertItem( tr("orange on black"), id_term_orange ); |
94 | 88 | ||
95 | // signals + slots | 89 | // signals + slots |
96 | /* | 90 | /* |
97 | connect(m_terminalBox, SIGNAL(activated(int) ), | 91 | connect(m_terminalBox, SIGNAL(activated(int) ), |
98 | this, SLOT(slotTermTerm(int) ) ); | 92 | this, SLOT(slotTermTerm(int) ) ); |
99 | connect(m_colorBox, SIGNAL(activated(int) ), | 93 | connect(m_colorBox, SIGNAL(activated(int) ), |
100 | tis, SLOT(slotTermColor(int) ) ); | 94 | tis, SLOT(slotTermColor(int) ) ); |
101 | connect(m_groupSize, SIGNAL(activated(int) ), | 95 | connect(m_groupSize, SIGNAL(activated(int) ), |
102 | this, SLOT(slotTermFont(int) ) ); | 96 | this, SLOT(slotTermFont(int) ) ); |
103 | 97 | ||
104 | connect(m_optionEcho, SIGNAL(toggled(bool) ), | 98 | connect(m_optionEcho, SIGNAL(toggled(bool) ), |
105 | this, SLOT(slotTermEcho(bool) ) ); | 99 | this, SLOT(slotTermEcho(bool) ) ); |
106 | connect(m_optionWrap, SIGNAL(toggled(bool) ), | 100 | connect(m_optionWrap, SIGNAL(toggled(bool) ), |
107 | this, SLOT(slotTermWrap(bool) ) ); | 101 | this, SLOT(slotTermWrap(bool) ) ); |
108 | connect(m_convInbound, SIGNAL(toggled(bool) ), | 102 | connect(m_convInbound, SIGNAL(toggled(bool) ), |
109 | this, SLOT(slotTermInbound(bool) ) ); | 103 | this, SLOT(slotTermInbound(bool) ) ); |
110 | connect(m_convOutbound, SIGNAL(toggled(bool) ), | 104 | connect(m_convOutbound, SIGNAL(toggled(bool) ), |
111 | this, SLOT(slotTermOutbound(bool) ) ); | 105 | this, SLOT(slotTermOutbound(bool) ) ); |
112 | */ | 106 | */ |
113 | } | 107 | } |
114 | TerminalWidget::~TerminalWidget() { | 108 | TerminalWidget::~TerminalWidget() { |
115 | } | 109 | } |
116 | void TerminalWidget::load( const Profile& prof ) { | 110 | void TerminalWidget::load( const Profile& prof ) { |
117 | int term = prof.readNumEntry("Terminal"); | 111 | int term = prof.readNumEntry("Terminal"); |
118 | int color = prof.readNumEntry("Color"); | 112 | int color = prof.readNumEntry("Color"); |
119 | // int fontsize = prof.readNumEntry("Font"); | 113 | // int fontsize = prof.readNumEntry("Font"); |
120 | int opt_echo = prof.readNumEntry("Echo"); | 114 | int opt_echo = prof.readNumEntry("Echo"); |
121 | int opt_wrap = prof.readNumEntry("Wrap"); | 115 | int opt_wrap = prof.readNumEntry("Wrap"); |
122 | int opt_inbound = prof.readNumEntry("Inbound"); | 116 | int opt_inbound = prof.readNumEntry("Inbound"); |
123 | int opt_outbound = prof.readNumEntry("Outbound"); | 117 | int opt_outbound = prof.readNumEntry("Outbound"); |
124 | 118 | ||
125 | switch( term ) { | 119 | switch( term ) { |
126 | case Profile::VT100: | 120 | case Profile::VT100: |
127 | m_terminalBox->setCurrentItem(id_term_vt100 ); | 121 | m_terminalBox->setCurrentItem(id_term_vt100 ); |
128 | break; | 122 | break; |
129 | case Profile::VT102: | 123 | case Profile::VT102: |
130 | m_terminalBox->setCurrentItem(id_term_vt102 ); | 124 | m_terminalBox->setCurrentItem(id_term_vt102 ); |
131 | break; | 125 | break; |
132 | case Profile::Linux: | 126 | case Profile::Linux: |
133 | m_terminalBox->setCurrentItem(id_term_linux ); | 127 | m_terminalBox->setCurrentItem(id_term_linux ); |
134 | break; | 128 | break; |
135 | case Profile::XTerm: | 129 | case Profile::XTerm: |
136 | m_terminalBox->setCurrentItem(id_term_xterm ); | 130 | m_terminalBox->setCurrentItem(id_term_xterm ); |
137 | break; | 131 | break; |
138 | default: | 132 | default: |
139 | m_terminalBox->setCurrentItem(id_term_vt102 ); | 133 | m_terminalBox->setCurrentItem(id_term_vt102 ); |
140 | break; | 134 | break; |
141 | }; | 135 | }; |
142 | 136 | ||
143 | switch( color ) { | 137 | switch( color ) { |
144 | case Profile::Black: | 138 | case Profile::Black: |
145 | m_colorCmb->setCurrentItem(id_term_black ); | 139 | m_colorCmb->setCurrentItem(id_term_black ); |
146 | break; | 140 | break; |
147 | case Profile::White: | 141 | case Profile::White: |
148 | m_colorCmb->setCurrentItem(id_term_white ); | 142 | m_colorCmb->setCurrentItem(id_term_white ); |
149 | break; | 143 | break; |
150 | case Profile::Green: | 144 | case Profile::Green: |
151 | m_colorCmb->setCurrentItem(id_term_green ); | 145 | m_colorCmb->setCurrentItem(id_term_green ); |
152 | break; | 146 | break; |
153 | case Profile::Orange: | 147 | case Profile::Orange: |
154 | m_colorCmb->setCurrentItem(id_term_orange ); | 148 | m_colorCmb->setCurrentItem(id_term_orange ); |
155 | break; | 149 | break; |
156 | default: | 150 | default: |
157 | break; | 151 | break; |
158 | }; | 152 | }; |
159 | 153 | ||
160 | 154 | ||
161 | m_fontSelector->setSelectedFont( prof.readEntry( "Font"), prof.readEntry( "FontStyle"), prof.readNumEntry( "FontSize" ), prof.readEntry( "FontCharset") ); | 155 | m_fontSelector->setSelectedFont( prof.readEntry( "Font"), prof.readEntry( "FontStyle"), prof.readNumEntry( "FontSize" ), prof.readEntry( "FontCharset") ); |
162 | 156 | ||
163 | // switch( fontsize ) { | 157 | // switch( fontsize ) { |
164 | // case Profile::Micro: | 158 | // case Profile::Micro: |
165 | // m_sizeSmall->setChecked(true ); | 159 | // m_sizeSmall->setChecked(true ); |
166 | // break; | 160 | // break; |
167 | // case Profile::Small: | 161 | // case Profile::Small: |
168 | // m_sizeMedium->setChecked(true ); | 162 | // m_sizeMedium->setChecked(true ); |
169 | // break; | 163 | // break; |
170 | // case Profile::Medium: | 164 | // case Profile::Medium: |
171 | // m_sizeLarge->setChecked( true ); | 165 | // m_sizeLarge->setChecked( true ); |
172 | // break; | 166 | // break; |
173 | // default: | 167 | // default: |
174 | // m_sizeMedium->setChecked(true ); | 168 | // m_sizeMedium->setChecked(true ); |
175 | // break; | 169 | // break; |
176 | // }; | 170 | // }; |
177 | 171 | ||
178 | if (opt_echo) m_optionEcho->setChecked( true ); | 172 | if (opt_echo) m_optionEcho->setChecked( true ); |
179 | if (opt_wrap) m_optionWrap->setChecked( true ); | 173 | if (opt_wrap) m_optionWrap->setChecked( true ); |
180 | if (opt_inbound) m_convInbound->setChecked( true ); | 174 | if (opt_inbound) m_convInbound->setChecked( true ); |
181 | if (opt_outbound) m_convOutbound->setChecked( true ); | 175 | if (opt_outbound) m_convOutbound->setChecked( true ); |
182 | 176 | ||
183 | } | 177 | } |
184 | void TerminalWidget::save( Profile& profile ) { | 178 | void TerminalWidget::save( Profile& profile ) { |
185 | switch(m_terminalBox->currentItem() ) { | 179 | switch(m_terminalBox->currentItem() ) { |
186 | case id_term_vt100: | 180 | case id_term_vt100: |
187 | profile.writeEntry("Terminal", Profile::VT100 ); | 181 | profile.writeEntry("Terminal", Profile::VT100 ); |
188 | break; | 182 | break; |
189 | case id_term_vt102: | 183 | case id_term_vt102: |
190 | profile.writeEntry("Terminal", Profile::VT102 ); | 184 | profile.writeEntry("Terminal", Profile::VT102 ); |
191 | break; | 185 | break; |
192 | case id_term_linux: | 186 | case id_term_linux: |
193 | profile.writeEntry("Terminal", Profile::Linux ); | 187 | profile.writeEntry("Terminal", Profile::Linux ); |
194 | break; | 188 | break; |
195 | case id_term_xterm: | 189 | case id_term_xterm: |
196 | profile.writeEntry("Terminal", Profile::XTerm ); | 190 | profile.writeEntry("Terminal", Profile::XTerm ); |
197 | break; | 191 | break; |
198 | //case id_term_ansi: | 192 | //case id_term_ansi: |
199 | // profile.writeEntry("Terminal", Profile::VT102 ); | 193 | // profile.writeEntry("Terminal", Profile::VT102 ); |
200 | // break; | 194 | // break; |
201 | default: | 195 | default: |
202 | break; | 196 | break; |
203 | }; | 197 | }; |
204 | 198 | ||
205 | // color | 199 | // color |
206 | switch(m_colorCmb->currentItem() ) { | 200 | switch(m_colorCmb->currentItem() ) { |
207 | case id_term_black: | 201 | case id_term_black: |
208 | profile.writeEntry("Color", Profile::Black ); | 202 | profile.writeEntry("Color", Profile::Black ); |
209 | break; | 203 | break; |
210 | case id_term_white: | 204 | case id_term_white: |
211 | profile.writeEntry("Color", Profile::White ); | 205 | profile.writeEntry("Color", Profile::White ); |
212 | break; | 206 | break; |
213 | case id_term_green: | 207 | case id_term_green: |
214 | profile.writeEntry("Color", Profile::Green ); | 208 | profile.writeEntry("Color", Profile::Green ); |
215 | break; | 209 | break; |
216 | case id_term_orange: | 210 | case id_term_orange: |
217 | profile.writeEntry("Color", Profile::Orange ); | 211 | profile.writeEntry("Color", Profile::Orange ); |
218 | break; | 212 | break; |
219 | default: | 213 | default: |
220 | break; | 214 | break; |
221 | }; | 215 | }; |
222 | 216 | ||
223 | 217 | ||
224 | profile.writeEntry( "FontSize", m_fontSelector->fontSize() ); | 218 | profile.writeEntry( "FontSize", m_fontSelector->fontSize() ); |
225 | profile.writeEntry( "FontStyle", m_fontSelector->fontStyle() ); | 219 | profile.writeEntry( "FontStyle", m_fontSelector->fontStyle() ); |
226 | profile.writeEntry( "FontCharset", m_fontSelector->fontCharSet() ); | 220 | profile.writeEntry( "FontCharset", m_fontSelector->fontCharSet() ); |
227 | profile.writeEntry( "Font", m_fontSelector->fontFamily() ); | 221 | profile.writeEntry( "Font", m_fontSelector->fontFamily() ); |
228 | 222 | ||
229 | 223 | ||
230 | // if (m_sizeSmall->isChecked() ) { | 224 | // if (m_sizeSmall->isChecked() ) { |
231 | // profile.writeEntry("Font", Profile::Micro ); | 225 | // profile.writeEntry("Font", Profile::Micro ); |
232 | // }else if (m_sizeMedium->isChecked() ) { | 226 | // }else if (m_sizeMedium->isChecked() ) { |
233 | // profile.writeEntry("Font", Profile::Small ); | 227 | // profile.writeEntry("Font", Profile::Small ); |
234 | // }else { | 228 | // }else { |
235 | // profile.writeEntry("Font", Profile::Medium ); | 229 | // profile.writeEntry("Font", Profile::Medium ); |
236 | // } | 230 | // } |
237 | 231 | ||
238 | profile.writeEntry("Echo", m_optionEcho->isChecked() ); | 232 | profile.writeEntry("Echo", m_optionEcho->isChecked() ); |
239 | profile.writeEntry("Wrap", m_optionWrap->isChecked() ); | 233 | profile.writeEntry("Wrap", m_optionWrap->isChecked() ); |
240 | profile.writeEntry("Inbound", m_convInbound->isChecked() ); | 234 | profile.writeEntry("Inbound", m_convInbound->isChecked() ); |
241 | profile.writeEntry("Outbound",m_convOutbound->isChecked() ); | 235 | profile.writeEntry("Outbound",m_convOutbound->isChecked() ); |
242 | } | 236 | } |
diff --git a/noncore/apps/opie-console/vt102emulation.cpp b/noncore/apps/opie-console/vt102emulation.cpp deleted file mode 100644 index 35b789c..0000000 --- a/noncore/apps/opie-console/vt102emulation.cpp +++ b/dev/null | |||
@@ -1,1024 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [vt102emulation.cpp] VT102 Terminal Emulation */ | ||
4 | /* */ | ||
5 | /* ------------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ------------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | |||
19 | /*! \class Vt102Emulation | ||
20 | |||
21 | \brief Actual Emulation for Konsole | ||
22 | |||
23 | \sa Widget \sa Screen \sa EmulationLayer | ||
24 | */ | ||
25 | |||
26 | #include "vt102emulation.h" | ||
27 | |||
28 | #include <stdio.h> | ||
29 | #include <unistd.h> | ||
30 | |||
31 | |||
32 | /* VT102 Terminal Emulation | ||
33 | |||
34 | This class puts together the screens, the pty and the widget to a | ||
35 | complete terminal emulation. Beside combining it's componentes, it | ||
36 | handles the emulations's protocol. | ||
37 | |||
38 | This module consists of the following sections: | ||
39 | |||
40 | - Constructor/Destructor | ||
41 | - Incoming Bytes Event pipeline | ||
42 | - Outgoing Bytes | ||
43 | - Mouse Events | ||
44 | - Keyboard Events | ||
45 | - Modes and Charset State | ||
46 | - Diagnostics | ||
47 | */ | ||
48 | |||
49 | |||
50 | /* ------------------------------------------------------------------------- */ | ||
51 | /* */ | ||
52 | /* Constructor / Destructor */ | ||
53 | /* */ | ||
54 | /* ------------------------------------------------------------------------- */ | ||
55 | |||
56 | /* | ||
57 | Nothing really intesting happens here. | ||
58 | */ | ||
59 | |||
60 | /*! | ||
61 | */ | ||
62 | |||
63 | Vt102Emulation::Vt102Emulation(WidgetLayer* gui) : EmulationLayer(gui) | ||
64 | { | ||
65 | QObject::connect(gui,SIGNAL(mouseSignal(int,int,int)), | ||
66 | this,SLOT(onMouse(int,int,int))); | ||
67 | initTokenizer(); | ||
68 | reset(); | ||
69 | } | ||
70 | |||
71 | /*! | ||
72 | */ | ||
73 | |||
74 | Vt102Emulation::~Vt102Emulation() | ||
75 | { | ||
76 | } | ||
77 | |||
78 | /*! | ||
79 | */ | ||
80 | |||
81 | void Vt102Emulation::reset() | ||
82 | { | ||
83 | resetToken(); | ||
84 | resetModes(); | ||
85 | resetCharset(0); screen[0]->reset(); | ||
86 | resetCharset(1); screen[0]->reset(); | ||
87 | setCodec(0); | ||
88 | setKeytrans("linux.keytab"); | ||
89 | } | ||
90 | |||
91 | /* ------------------------------------------------------------------------- */ | ||
92 | /* */ | ||
93 | /* Processing the incoming byte stream */ | ||
94 | /* */ | ||
95 | /* ------------------------------------------------------------------------- */ | ||
96 | |||
97 | /* Incoming Bytes Event pipeline | ||
98 | |||
99 | This section deals with decoding the incoming character stream. | ||
100 | Decoding means here, that the stream is first seperated into `tokens' | ||
101 | which are then mapped to a `meaning' provided as operations by the | ||
102 | `TEScreen' class or by the emulation class itself. | ||
103 | |||
104 | The pipeline proceeds as follows: | ||
105 | |||
106 | - Tokenizing the ESC codes (onRcvChar) | ||
107 | - VT100 code page translation of plain characters (applyCharset) | ||
108 | - Interpretation of ESC codes (tau) | ||
109 | |||
110 | The escape codes and their meaning are described in the | ||
111 | technical reference of this program. | ||
112 | */ | ||
113 | |||
114 | // Tokens ------------------------------------------------------------------ -- | ||
115 | |||
116 | /* | ||
117 | Since the tokens are the central notion if this section, we've put them | ||
118 | in front. They provide the syntactical elements used to represent the | ||
119 | terminals operations as byte sequences. | ||
120 | |||
121 | They are encodes here into a single machine word, so that we can later | ||
122 | switch over them easily. Depending on the token itself, additional | ||
123 | argument variables are filled with parameter values. | ||
124 | |||
125 | The tokens are defined below: | ||
126 | |||
127 | - CHR - Printable characters (32..255 but DEL (=127)) | ||
128 | - CTL - Control characters (0..31 but ESC (= 27), DEL) | ||
129 | - ESC - Escape codes of the form <ESC><CHR but `[]()+*#'> | ||
130 | - ESC_DE - Escape codes of the form <ESC><any of `()+*#%'> C | ||
131 | - CSI_PN - Escape codes of the form <ESC>'[' {Pn} ';' {Pn} C | ||
132 | - CSI_PS - Escape codes of the form <ESC>'[' {Pn} ';' ... C | ||
133 | - CSI_PR - Escape codes of the form <ESC>'[' '?' {Pn} ';' ... C | ||
134 | - VT52 - VT52 escape codes | ||
135 | - <ESC><Chr> | ||
136 | - <ESC>'Y'{Pc}{Pc} | ||
137 | - XTE_HA - Xterm hacks <ESC>`]' {Pn} `;' {Text} <BEL> | ||
138 | note that this is handled differently | ||
139 | |||
140 | The last two forms allow list of arguments. Since the elements of | ||
141 | the lists are treated individually the same way, they are passed | ||
142 | as individual tokens to the interpretation. Further, because the | ||
143 | meaning of the parameters are names (althought represented as numbers), | ||
144 | they are includes within the token ('N'). | ||
145 | |||
146 | */ | ||
147 | |||
148 | #define TY_CONSTR(T,A,N) ( ((((int)N) & 0xffff) << 16) | ((((int)A) & 0xff) << 8) | (((int)T) & 0xff) ) | ||
149 | |||
150 | #define TY_CHR___( ) TY_CONSTR(0,0,0) | ||
151 | #define TY_CTL___(A ) TY_CONSTR(1,A,0) | ||
152 | #define TY_ESC___(A ) TY_CONSTR(2,A,0) | ||
153 | #define TY_ESC_CS(A,B) TY_CONSTR(3,A,B) | ||
154 | #define TY_ESC_DE(A ) TY_CONSTR(4,A,0) | ||
155 | #define TY_CSI_PS(A,N) TY_CONSTR(5,A,N) | ||
156 | #define TY_CSI_PN(A ) TY_CONSTR(6,A,0) | ||
157 | #define TY_CSI_PR(A,N) TY_CONSTR(7,A,N) | ||
158 | |||
159 | #define TY_VT52__(A ) TY_CONSTR(8,A,0) | ||
160 | |||
161 | // Tokenizer --------------------------------------------------------------- -- | ||
162 | |||
163 | /* The tokenizers state | ||
164 | |||
165 | The state is represented by the buffer (pbuf, ppos), | ||
166 | and accompanied by decoded arguments kept in (argv,argc). | ||
167 | Note that they are kept internal in the tokenizer. | ||
168 | */ | ||
169 | |||
170 | void Vt102Emulation::resetToken() | ||
171 | { | ||
172 | ppos = 0; argc = 0; argv[0] = 0; argv[1] = 0; | ||
173 | } | ||
174 | |||
175 | void Vt102Emulation::addDigit(int dig) | ||
176 | { | ||
177 | argv[argc] = 10*argv[argc] + dig; | ||
178 | } | ||
179 | |||
180 | void Vt102Emulation::addArgument() | ||
181 | { | ||
182 | argc = QMIN(argc+1,MAXARGS-1); | ||
183 | argv[argc] = 0; | ||
184 | } | ||
185 | |||
186 | void Vt102Emulation::pushToToken(int cc) | ||
187 | { | ||
188 | pbuf[ppos] = cc; | ||
189 | ppos = QMIN(ppos+1,MAXPBUF-1); | ||
190 | } | ||
191 | |||
192 | // Character Classes used while decoding | ||
193 | |||
194 | #define CTL 1 | ||
195 | #define CHR 2 | ||
196 | #define CPN 4 | ||
197 | #define DIG 8 | ||
198 | #define SCS 16 | ||
199 | #define GRP 32 | ||
200 | |||
201 | void Vt102Emulation::initTokenizer() | ||
202 | { int i; UINT8* s; | ||
203 | for(i = 0; i < 256; i++) tbl[ i] = 0; | ||
204 | for(i = 0; i < 32; i++) tbl[ i] |= CTL; | ||
205 | for(i = 32; i < 256; i++) tbl[ i] |= CHR; | ||
206 | for(s = (UINT8*)"@ABCDGHLMPXcdfry"; *s; s++) tbl[*s] |= CPN; | ||
207 | for(s = (UINT8*)"0123456789" ; *s; s++) tbl[*s] |= DIG; | ||
208 | for(s = (UINT8*)"()+*%" ; *s; s++) tbl[*s] |= SCS; | ||
209 | for(s = (UINT8*)"()+*#[]%" ; *s; s++) tbl[*s] |= GRP; | ||
210 | resetToken(); | ||
211 | } | ||
212 | |||
213 | /* Ok, here comes the nasty part of the decoder. | ||
214 | |||
215 | Instead of keeping an explicit state, we deduce it from the | ||
216 | token scanned so far. It is then immediately combined with | ||
217 | the current character to form a scanning decision. | ||
218 | |||
219 | This is done by the following defines. | ||
220 | |||
221 | - P is the length of the token scanned so far. | ||
222 | - L (often P-1) is the position on which contents we base a decision. | ||
223 | - C is a character or a group of characters (taken from 'tbl'). | ||
224 | |||
225 | Note that they need to applied in proper order. | ||
226 | */ | ||
227 | |||
228 | #define lec(P,L,C) (p == (P) && s[(L)] == (C)) | ||
229 | #define lun( ) (p == 1 && cc >= 32 ) | ||
230 | #define les(P,L,C) (p == (P) && s[L] < 256 && (tbl[s[(L)]] & (C)) == (C)) | ||
231 | #define eec(C) (p >= 3 && cc == (C)) | ||
232 | #define ees(C) (p >= 3 && cc < 256 && (tbl[ cc ] & (C)) == (C)) | ||
233 | #define eps(C) (p >= 3 && s[2] != '?' && cc < 256 && (tbl[ cc ] & (C)) == (C)) | ||
234 | #define epp( ) (p >= 3 && s[2] == '?' ) | ||
235 | #define egt( ) (p == 3 && s[2] == '>' ) | ||
236 | #define Xpe (ppos>=2 && pbuf[1] == ']' ) | ||
237 | #define Xte (Xpe && cc == 7 ) | ||
238 | #define ces(C) ( cc < 256 && (tbl[ cc ] & (C)) == (C) && !Xte) | ||
239 | |||
240 | #define ESC 27 | ||
241 | #define CNTL(c) ((c)-'@') | ||
242 | |||
243 | // process an incoming unicode character | ||
244 | |||
245 | void Vt102Emulation::onRcvChar(int cc) | ||
246 | { int i; | ||
247 | |||
248 | if (cc == 127) return; //VT100: ignore. | ||
249 | |||
250 | if (ces( CTL)) | ||
251 | { // DEC HACK ALERT! Control Characters are allowed *within* esc sequences in VT100 | ||
252 | // This means, they do neither a resetToken nor a pushToToken. Some of them, do | ||
253 | // of course. Guess this originates from a weakly layered handling of the X-on | ||
254 | // X-off protocol, which comes really below this level. | ||
255 | if (cc == CNTL('X') || cc == CNTL('Z') || cc == ESC) resetToken(); //VT100: CAN or SUB | ||
256 | if (cc != ESC) { tau( TY_CTL___(cc+'@' ), 0, 0); return; } | ||
257 | } | ||
258 | |||
259 | pushToToken(cc); // advance the state | ||
260 | |||
261 | int* s = pbuf; | ||
262 | int p = ppos; | ||
263 | |||
264 | if (getMode(MODE_Ansi)) // decide on proper action | ||
265 | { | ||
266 | if (lec(1,0,ESC)) { return; } | ||
267 | if (les(2,1,GRP)) { return; } | ||
268 | if (Xte ) { XtermHack(); resetToken(); return; } | ||
269 | if (Xpe ) { return; } | ||
270 | if (lec(3,2,'?')) { return; } | ||
271 | if (lec(3,2,'>')) { return; } | ||
272 | if (lun( )) { tau( TY_CHR___(), applyCharset(cc), 0); resetToken(); return; } | ||
273 | if (lec(2,0,ESC)) { tau( TY_ESC___(s[1]), 0, 0); resetToken(); return; } | ||
274 | if (les(3,1,SCS)) { tau( TY_ESC_CS(s[1],s[2]), 0, 0); resetToken(); return; } | ||
275 | if (lec(3,1,'#')) { tau( TY_ESC_DE(s[2]), 0, 0); resetToken(); return; } | ||
276 | // if (egt( )) { tau( TY_CSI_PG(cc ), '>', 0); resetToken(); return; } | ||
277 | if (eps( CPN)) { tau( TY_CSI_PN(cc), argv[0],argv[1]); resetToken(); return; } | ||
278 | if (ees( DIG)) { addDigit(cc-'0'); return; } | ||
279 | if (eec( ';')) { addArgument(); return; } | ||
280 | for (i=0;i<=argc;i++) | ||
281 | if (epp( )) tau( TY_CSI_PR(cc,argv[i]), 0, 0); else | ||
282 | tau( TY_CSI_PS(cc,argv[i]), 0, 0); | ||
283 | resetToken(); | ||
284 | } | ||
285 | else // mode VT52 | ||
286 | { | ||
287 | if (lec(1,0,ESC)) return; | ||
288 | if (les(1,0,CHR)) { tau( TY_CHR___( ), s[0], 0); resetToken(); return; } | ||
289 | if (lec(2,1,'Y')) return; | ||
290 | if (lec(3,1,'Y')) return; | ||
291 | if (p < 4) { tau( TY_VT52__(s[1] ), 0, 0); resetToken(); return; } | ||
292 | tau( TY_VT52__(s[1] ), s[2],s[3]); resetToken(); return; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | void Vt102Emulation::XtermHack() | ||
297 | { int i,arg = 0; | ||
298 | for (i = 2; i < ppos && '0'<=pbuf[i] && pbuf[i]<'9' ; i++) | ||
299 | arg = 10*arg + (pbuf[i]-'0'); | ||
300 | if (pbuf[i] != ';') { ReportErrorToken(); return; } | ||
301 | QChar *str = new QChar[ppos-i-2]; | ||
302 | for (int j = 0; j < ppos-i-2; j++) str[j] = pbuf[i+1+j]; | ||
303 | QString unistr(str,ppos-i-2); | ||
304 | // arg == 1 doesn't change the title. In XTerm it only changes the icon name | ||
305 | // (btw: arg=0 changes title and icon, arg=1 only icon, arg=2 only title | ||
306 | if (arg == 0 || arg == 2) emit changeTitle(arg,unistr); | ||
307 | delete [] str; | ||
308 | } | ||
309 | |||
310 | // Interpreting Codes --------------------------------------------------------- | ||
311 | |||
312 | /* | ||
313 | Now that the incoming character stream is properly tokenized, | ||
314 | meaning is assigned to them. These are either operations of | ||
315 | the current screen, or of the emulation class itself. | ||
316 | |||
317 | The token to be interpreteted comes in as a machine word | ||
318 | possibly accompanied by two parameters. | ||
319 | |||
320 | Likewise, the operations assigned to, come with up to two | ||
321 | arguments. One could consider to make up a proper table | ||
322 | from the function below. | ||
323 | |||
324 | The technical reference manual provides more informations | ||
325 | about this mapping. | ||
326 | */ | ||
327 | |||
328 | void Vt102Emulation::tau( int token, int p, int q ) | ||
329 | { | ||
330 | //scan_buffer_report(); | ||
331 | //if (token == TY_CHR___()) printf("%c",p); else | ||
332 | //printf("tau(%d,%d,%d, %d,%d)\n",(token>>0)&0xff,(token>>8)&0xff,(token>>16)&0xffff,p,q); | ||
333 | switch (token) | ||
334 | { | ||
335 | |||
336 | case TY_CHR___( ) : scr->ShowCharacter (p ); break; //UTF16 | ||
337 | |||
338 | // 127 DEL : ignored on input | ||
339 | |||
340 | case TY_CTL___('@' ) : /* NUL: ignored */ break; | ||
341 | case TY_CTL___('A' ) : /* SOH: ignored */ break; | ||
342 | case TY_CTL___('B' ) : /* STX: ignored */ break; | ||
343 | case TY_CTL___('C' ) : /* ETX: ignored */ break; | ||
344 | case TY_CTL___('D' ) : /* EOT: ignored */ break; | ||
345 | case TY_CTL___('E' ) : reportAnswerBack ( ); break; //VT100 | ||
346 | case TY_CTL___('F' ) : /* ACK: ignored */ break; | ||
347 | case TY_CTL___('G' ) : gui->bell ( ); break; //VT100 | ||
348 | case TY_CTL___('H' ) : scr->BackSpace ( ); break; //VT100 | ||
349 | case TY_CTL___('I' ) : scr->Tabulate ( ); break; //VT100 | ||
350 | case TY_CTL___('J' ) : scr->NewLine ( ); break; //VT100 | ||
351 | case TY_CTL___('K' ) : scr->NewLine ( ); break; //VT100 | ||
352 | case TY_CTL___('L' ) : scr->NewLine ( ); break; //VT100 | ||
353 | case TY_CTL___('M' ) : scr->Return ( ); break; //VT100 | ||
354 | |||
355 | case TY_CTL___('N' ) : useCharset ( 1); break; //VT100 | ||
356 | case TY_CTL___('O' ) : useCharset ( 0); break; //VT100 | ||
357 | |||
358 | case TY_CTL___('P' ) : /* DLE: ignored */ break; | ||
359 | case TY_CTL___('Q' ) : /* DC1: XON continue */ break; //VT100 | ||
360 | case TY_CTL___('R' ) : /* DC2: ignored */ break; | ||
361 | case TY_CTL___('S' ) : /* DC3: XOFF halt */ break; //VT100 | ||
362 | case TY_CTL___('T' ) : /* DC4: ignored */ break; | ||
363 | case TY_CTL___('U' ) : /* NAK: ignored */ break; | ||
364 | case TY_CTL___('V' ) : /* SYN: ignored */ break; | ||
365 | case TY_CTL___('W' ) : /* ETB: ignored */ break; | ||
366 | case TY_CTL___('X' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | ||
367 | case TY_CTL___('Y' ) : /* EM : ignored */ break; | ||
368 | case TY_CTL___('Z' ) : scr->ShowCharacter ( 0x2592); break; //VT100 | ||
369 | case TY_CTL___('[' ) : /* ESC: cannot be seen here. */ break; | ||
370 | case TY_CTL___('\\' ) : /* FS : ignored */ break; | ||
371 | case TY_CTL___(']' ) : /* GS : ignored */ break; | ||
372 | case TY_CTL___('^' ) : /* RS : ignored */ break; | ||
373 | case TY_CTL___('_' ) : /* US : ignored */ break; | ||
374 | |||
375 | case TY_ESC___('D' ) : scr->index ( ); break; //VT100 | ||
376 | case TY_ESC___('E' ) : scr->NextLine ( ); break; //VT100 | ||
377 | case TY_ESC___('H' ) : scr->changeTabStop (TRUE ); break; //VT100 | ||
378 | case TY_ESC___('M' ) : scr->reverseIndex ( ); break; //VT100 | ||
379 | case TY_ESC___('Z' ) : reportTerminalType ( ); break; | ||
380 | case TY_ESC___('c' ) : reset ( ); break; | ||
381 | |||
382 | case TY_ESC___('n' ) : useCharset ( 2); break; | ||
383 | case TY_ESC___('o' ) : useCharset ( 3); break; | ||
384 | case TY_ESC___('7' ) : saveCursor ( ); break; | ||
385 | case TY_ESC___('8' ) : restoreCursor ( ); break; | ||
386 | |||
387 | case TY_ESC___('=' ) : setMode (MODE_AppKeyPad); break; | ||
388 | case TY_ESC___('>' ) : resetMode (MODE_AppKeyPad); break; | ||
389 | case TY_ESC___('<' ) : setMode (MODE_Ansi ); break; //VT100 | ||
390 | |||
391 | case TY_ESC_CS('(', '0') : setCharset (0, '0'); break; //VT100 | ||
392 | case TY_ESC_CS('(', 'A') : setCharset (0, 'A'); break; //VT100 | ||
393 | case TY_ESC_CS('(', 'B') : setCharset (0, 'B'); break; //VT100 | ||
394 | |||
395 | case TY_ESC_CS(')', '0') : setCharset (1, '0'); break; //VT100 | ||
396 | case TY_ESC_CS(')', 'A') : setCharset (1, 'A'); break; //VT100 | ||
397 | case TY_ESC_CS(')', 'B') : setCharset (1, 'B'); break; //VT100 | ||
398 | |||
399 | case TY_ESC_CS('*', '0') : setCharset (2, '0'); break; //VT100 | ||
400 | case TY_ESC_CS('*', 'A') : setCharset (2, 'A'); break; //VT100 | ||
401 | case TY_ESC_CS('*', 'B') : setCharset (2, 'B'); break; //VT100 | ||
402 | |||
403 | case TY_ESC_CS('+', '0') : setCharset (3, '0'); break; //VT100 | ||
404 | case TY_ESC_CS('+', 'A') : setCharset (3, 'A'); break; //VT100 | ||
405 | case TY_ESC_CS('+', 'B') : setCharset (3, 'B'); break; //VT100 | ||
406 | |||
407 | case TY_ESC_CS('%', 'G') : setCodec (1 ); break; //LINUX | ||
408 | case TY_ESC_CS('%', '@') : setCodec (0 ); break; //LINUX | ||
409 | |||
410 | case TY_ESC_DE('3' ) : /* IGNORED: double high, top half */ break; | ||
411 | case TY_ESC_DE('4' ) : /* IGNORED: double high, bottom half */ break; | ||
412 | case TY_ESC_DE('5' ) : /* IGNORED: single width, single high*/ break; | ||
413 | case TY_ESC_DE('6' ) : /* IGNORED: double width, single high*/ break; | ||
414 | case TY_ESC_DE('8' ) : scr->helpAlign ( ); break; | ||
415 | |||
416 | case TY_CSI_PS('K', 0) : scr->clearToEndOfLine ( ); break; | ||
417 | case TY_CSI_PS('K', 1) : scr->clearToBeginOfLine ( ); break; | ||
418 | case TY_CSI_PS('K', 2) : scr->clearEntireLine ( ); break; | ||
419 | case TY_CSI_PS('J', 0) : scr->clearToEndOfScreen ( ); break; | ||
420 | case TY_CSI_PS('J', 1) : scr->clearToBeginOfScreen ( ); break; | ||
421 | case TY_CSI_PS('J', 2) : scr->clearEntireScreen ( ); break; | ||
422 | case TY_CSI_PS('g', 0) : scr->changeTabStop (FALSE ); break; //VT100 | ||
423 | case TY_CSI_PS('g', 3) : scr->clearTabStops ( ); break; //VT100 | ||
424 | case TY_CSI_PS('h', 4) : scr-> setMode (MODE_Insert ); break; | ||
425 | case TY_CSI_PS('h', 20) : setMode (MODE_NewLine ); break; | ||
426 | case TY_CSI_PS('i', 0) : /* IGNORE: attached printer */ break; //VT100 | ||
427 | case TY_CSI_PS('l', 4) : scr-> resetMode (MODE_Insert ); break; | ||
428 | case TY_CSI_PS('l', 20) : resetMode (MODE_NewLine ); break; | ||
429 | |||
430 | case TY_CSI_PS('m', 0) : scr->setDefaultRendition ( ); break; | ||
431 | case TY_CSI_PS('m', 1) : scr-> setRendition (RE_BOLD ); break; //VT100 | ||
432 | case TY_CSI_PS('m', 4) : scr-> setRendition (RE_UNDERLINE); break; //VT100 | ||
433 | case TY_CSI_PS('m', 5) : scr-> setRendition (RE_BLINK ); break; //VT100 | ||
434 | case TY_CSI_PS('m', 7) : scr-> setRendition (RE_REVERSE ); break; | ||
435 | case TY_CSI_PS('m', 10) : /* IGNORED: mapping related */ break; //LINUX | ||
436 | case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX | ||
437 | case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX | ||
438 | case TY_CSI_PS('m', 22) : scr->resetRendition (RE_BOLD ); break; | ||
439 | case TY_CSI_PS('m', 24) : scr->resetRendition (RE_UNDERLINE); break; | ||
440 | case TY_CSI_PS('m', 25) : scr->resetRendition (RE_BLINK ); break; | ||
441 | case TY_CSI_PS('m', 27) : scr->resetRendition (RE_REVERSE ); break; | ||
442 | |||
443 | case TY_CSI_PS('m', 30) : scr->setForeColor ( 0); break; | ||
444 | case TY_CSI_PS('m', 31) : scr->setForeColor ( 1); break; | ||
445 | case TY_CSI_PS('m', 32) : scr->setForeColor ( 2); break; | ||
446 | case TY_CSI_PS('m', 33) : scr->setForeColor ( 3); break; | ||
447 | case TY_CSI_PS('m', 34) : scr->setForeColor ( 4); break; | ||
448 | case TY_CSI_PS('m', 35) : scr->setForeColor ( 5); break; | ||
449 | case TY_CSI_PS('m', 36) : scr->setForeColor ( 6); break; | ||
450 | case TY_CSI_PS('m', 37) : scr->setForeColor ( 7); break; | ||
451 | case TY_CSI_PS('m', 39) : scr->setForeColorToDefault( ); break; | ||
452 | |||
453 | case TY_CSI_PS('m', 40) : scr->setBackColor ( 0); break; | ||
454 | case TY_CSI_PS('m', 41) : scr->setBackColor ( 1); break; | ||
455 | case TY_CSI_PS('m', 42) : scr->setBackColor ( 2); break; | ||
456 | case TY_CSI_PS('m', 43) : scr->setBackColor ( 3); break; | ||
457 | case TY_CSI_PS('m', 44) : scr->setBackColor ( 4); break; | ||
458 | case TY_CSI_PS('m', 45) : scr->setBackColor ( 5); break; | ||
459 | case TY_CSI_PS('m', 46) : scr->setBackColor ( 6); break; | ||
460 | case TY_CSI_PS('m', 47) : scr->setBackColor ( 7); break; | ||
461 | case TY_CSI_PS('m', 49) : scr->setBackColorToDefault( ); break; | ||
462 | |||
463 | case TY_CSI_PS('m', 90) : scr->setForeColor ( 8); break; | ||
464 | case TY_CSI_PS('m', 91) : scr->setForeColor ( 9); break; | ||
465 | case TY_CSI_PS('m', 92) : scr->setForeColor ( 10); break; | ||
466 | case TY_CSI_PS('m', 93) : scr->setForeColor ( 11); break; | ||
467 | case TY_CSI_PS('m', 94) : scr->setForeColor ( 12); break; | ||
468 | case TY_CSI_PS('m', 95) : scr->setForeColor ( 13); break; | ||
469 | case TY_CSI_PS('m', 96) : scr->setForeColor ( 14); break; | ||
470 | case TY_CSI_PS('m', 97) : scr->setForeColor ( 15); break; | ||
471 | |||
472 | case TY_CSI_PS('m', 100) : scr->setBackColor ( 8); break; | ||
473 | case TY_CSI_PS('m', 101) : scr->setBackColor ( 9); break; | ||
474 | case TY_CSI_PS('m', 102) : scr->setBackColor ( 10); break; | ||
475 | case TY_CSI_PS('m', 103) : scr->setBackColor ( 11); break; | ||
476 | case TY_CSI_PS('m', 104) : scr->setBackColor ( 12); break; | ||
477 | case TY_CSI_PS('m', 105) : scr->setBackColor ( 13); break; | ||
478 | case TY_CSI_PS('m', 106) : scr->setBackColor ( 14); break; | ||
479 | case TY_CSI_PS('m', 107) : scr->setBackColor ( 15); break; | ||
480 | |||
481 | case TY_CSI_PS('n', 5) : reportStatus ( ); break; | ||
482 | case TY_CSI_PS('n', 6) : reportCursorPosition ( ); break; | ||
483 | case TY_CSI_PS('q', 0) : /* IGNORED: LEDs off */ break; //VT100 | ||
484 | case TY_CSI_PS('q', 1) : /* IGNORED: LED1 on */ break; //VT100 | ||
485 | case TY_CSI_PS('q', 2) : /* IGNORED: LED2 on */ break; //VT100 | ||
486 | case TY_CSI_PS('q', 3) : /* IGNORED: LED3 on */ break; //VT100 | ||
487 | case TY_CSI_PS('q', 4) : /* IGNORED: LED4 on */ break; //VT100 | ||
488 | case TY_CSI_PS('x', 0) : reportTerminalParms ( 2); break; //VT100 | ||
489 | case TY_CSI_PS('x', 1) : reportTerminalParms ( 3); break; //VT100 | ||
490 | |||
491 | case TY_CSI_PN('@' ) : scr->insertChars (p ); break; | ||
492 | case TY_CSI_PN('A' ) : scr->cursorUp (p ); break; //VT100 | ||
493 | case TY_CSI_PN('B' ) : scr->cursorDown (p ); break; //VT100 | ||
494 | case TY_CSI_PN('C' ) : scr->cursorRight (p ); break; //VT100 | ||
495 | case TY_CSI_PN('D' ) : scr->cursorLeft (p ); break; //VT100 | ||
496 | case TY_CSI_PN('G' ) : scr->setCursorX (p ); break; //LINUX | ||
497 | case TY_CSI_PN('H' ) : scr->setCursorYX (p, q); break; //VT100 | ||
498 | case TY_CSI_PN('L' ) : scr->insertLines (p ); break; | ||
499 | case TY_CSI_PN('M' ) : scr->deleteLines (p ); break; | ||
500 | case TY_CSI_PN('P' ) : scr->deleteChars (p ); break; | ||
501 | case TY_CSI_PN('X' ) : scr->eraseChars (p ); break; | ||
502 | case TY_CSI_PN('c' ) : reportTerminalType ( ); break; //VT100 | ||
503 | case TY_CSI_PN('d' ) : scr->setCursorY (p ); break; //LINUX | ||
504 | case TY_CSI_PN('f' ) : scr->setCursorYX (p, q); break; //VT100 | ||
505 | case TY_CSI_PN('r' ) : scr->setMargins (p, q); break; //VT100 | ||
506 | case TY_CSI_PN('y' ) : /* IGNORED: Confidence test */ break; //VT100 | ||
507 | |||
508 | case TY_CSI_PR('h', 1) : setMode (MODE_AppCuKeys); break; //VT100 | ||
509 | case TY_CSI_PR('l', 1) : resetMode (MODE_AppCuKeys); break; //VT100 | ||
510 | case TY_CSI_PR('s', 1) : saveMode (MODE_AppCuKeys); break; //FIXME | ||
511 | case TY_CSI_PR('r', 1) : restoreMode (MODE_AppCuKeys); break; //FIXME | ||
512 | |||
513 | case TY_CSI_PR('l', 2) : resetMode (MODE_Ansi ); break; //VT100 | ||
514 | |||
515 | case TY_CSI_PR('h', 3) : setColumns ( 132); break; //VT100 | ||
516 | case TY_CSI_PR('l', 3) : setColumns ( 80); break; //VT100 | ||
517 | |||
518 | case TY_CSI_PR('h', 4) : /* IGNORED: soft scrolling */ break; //VT100 | ||
519 | case TY_CSI_PR('l', 4) : /* IGNORED: soft scrolling */ break; //VT100 | ||
520 | |||
521 | case TY_CSI_PR('h', 5) : scr-> setMode (MODE_Screen ); break; //VT100 | ||
522 | case TY_CSI_PR('l', 5) : scr-> resetMode (MODE_Screen ); break; //VT100 | ||
523 | |||
524 | case TY_CSI_PR('h', 6) : scr-> setMode (MODE_Origin ); break; //VT100 | ||
525 | case TY_CSI_PR('l', 6) : scr-> resetMode (MODE_Origin ); break; //VT100 | ||
526 | case TY_CSI_PR('s', 6) : scr-> saveMode (MODE_Origin ); break; //FIXME | ||
527 | case TY_CSI_PR('r', 6) : scr->restoreMode (MODE_Origin ); break; //FIXME | ||
528 | |||
529 | case TY_CSI_PR('h', 7) : scr-> setMode (MODE_Wrap ); break; //VT100 | ||
530 | case TY_CSI_PR('l', 7) : scr-> resetMode (MODE_Wrap ); break; //VT100 | ||
531 | case TY_CSI_PR('s', 7) : scr-> saveMode (MODE_Wrap ); break; //FIXME | ||
532 | case TY_CSI_PR('r', 7) : scr->restoreMode (MODE_Wrap ); break; //FIXME | ||
533 | |||
534 | case TY_CSI_PR('h', 8) : /* IGNORED: autorepeat on */ break; //VT100 | ||
535 | case TY_CSI_PR('l', 8) : /* IGNORED: autorepeat off */ break; //VT100 | ||
536 | |||
537 | case TY_CSI_PR('h', 9) : /* IGNORED: interlace */ break; //VT100 | ||
538 | case TY_CSI_PR('l', 9) : /* IGNORED: interlace */ break; //VT100 | ||
539 | |||
540 | case TY_CSI_PR('h', 25) : setMode (MODE_Cursor ); break; //VT100 | ||
541 | case TY_CSI_PR('l', 25) : resetMode (MODE_Cursor ); break; //VT100 | ||
542 | |||
543 | case TY_CSI_PR('h', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
544 | case TY_CSI_PR('l', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
545 | case TY_CSI_PR('s', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
546 | case TY_CSI_PR('r', 41) : /* IGNORED: obsolete more(1) fix */ break; //XTERM | ||
547 | |||
548 | case TY_CSI_PR('h', 47) : setMode (MODE_AppScreen); break; //VT100 | ||
549 | case TY_CSI_PR('l', 47) : resetMode (MODE_AppScreen); break; //VT100 | ||
550 | |||
551 | case TY_CSI_PR('h', 1000) : setMode (MODE_Mouse1000); break; //XTERM | ||
552 | case TY_CSI_PR('l', 1000) : resetMode (MODE_Mouse1000); break; //XTERM | ||
553 | case TY_CSI_PR('s', 1000) : saveMode (MODE_Mouse1000); break; //XTERM | ||
554 | case TY_CSI_PR('r', 1000) : restoreMode (MODE_Mouse1000); break; //XTERM | ||
555 | |||
556 | case TY_CSI_PR('h', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
557 | case TY_CSI_PR('l', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
558 | case TY_CSI_PR('s', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
559 | case TY_CSI_PR('r', 1001) : /* IGNORED: hilite mouse tracking */ break; //XTERM | ||
560 | |||
561 | case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM | ||
562 | case TY_CSI_PR('l', 1047) : resetMode (MODE_AppScreen); break; //XTERM | ||
563 | |||
564 | //FIXME: Unitoken: save translations | ||
565 | case TY_CSI_PR('h', 1048) : saveCursor ( ); break; //XTERM | ||
566 | case TY_CSI_PR('l', 1048) : restoreCursor ( ); break; //XTERM | ||
567 | |||
568 | //FIXME: every once new sequences like this pop up in xterm. | ||
569 | // Here's a guess of what they could mean. | ||
570 | case TY_CSI_PR('h', 1049) : setMode (MODE_AppScreen); break; //XTERM | ||
571 | case TY_CSI_PR('l', 1049) : resetMode (MODE_AppScreen); break; //XTERM | ||
572 | |||
573 | //FIXME: when changing between vt52 and ansi mode evtl do some resetting. | ||
574 | case TY_VT52__('A' ) : scr->cursorUp ( 1); break; //VT52 | ||
575 | case TY_VT52__('B' ) : scr->cursorDown ( 1); break; //VT52 | ||
576 | case TY_VT52__('C' ) : scr->cursorRight ( 1); break; //VT52 | ||
577 | case TY_VT52__('D' ) : scr->cursorLeft ( 1); break; //VT52 | ||
578 | |||
579 | case TY_VT52__('F' ) : setAndUseCharset (0, '0'); break; //VT52 | ||
580 | case TY_VT52__('G' ) : setAndUseCharset (0, 'B'); break; //VT52 | ||
581 | |||
582 | case TY_VT52__('H' ) : scr->setCursorYX (1,1 ); break; //VT52 | ||
583 | case TY_VT52__('I' ) : scr->reverseIndex ( ); break; //VT52 | ||
584 | case TY_VT52__('J' ) : scr->clearToEndOfScreen ( ); break; //VT52 | ||
585 | case TY_VT52__('K' ) : scr->clearToEndOfLine ( ); break; //VT52 | ||
586 | case TY_VT52__('Y' ) : scr->setCursorYX (p-31,q-31 ); break; //VT52 | ||
587 | case TY_VT52__('Z' ) : reportTerminalType ( ); break; //VT52 | ||
588 | case TY_VT52__('<' ) : setMode (MODE_Ansi ); break; //VT52 | ||
589 | case TY_VT52__('=' ) : setMode (MODE_AppKeyPad); break; //VT52 | ||
590 | case TY_VT52__('>' ) : resetMode (MODE_AppKeyPad); break; //VT52 | ||
591 | |||
592 | default : ReportErrorToken(); break; | ||
593 | }; | ||
594 | } | ||
595 | |||
596 | /* ------------------------------------------------------------------------- */ | ||
597 | /* */ | ||
598 | /* Terminal to Host protocol */ | ||
599 | /* */ | ||
600 | /* ------------------------------------------------------------------------- */ | ||
601 | |||
602 | /* | ||
603 | Outgoing bytes originate from several sources: | ||
604 | |||
605 | - Replies to Enquieries. | ||
606 | - Mouse Events | ||
607 | - Keyboard Events | ||
608 | */ | ||
609 | |||
610 | /*! | ||
611 | */ | ||
612 | |||
613 | void Vt102Emulation::sendString(const char* s) | ||
614 | { | ||
615 | QByteArray tmp; | ||
616 | tmp.setRawData( s, strlen( s )); | ||
617 | emit sndBlock( tmp); | ||
618 | } | ||
619 | |||
620 | void Vt102Emulation::sendString(const QByteArray& s) | ||
621 | { | ||
622 | emit sndBlock( s ); | ||
623 | } | ||
624 | |||
625 | // Replies ----------------------------------------------------------------- -- | ||
626 | |||
627 | // This section copes with replies send as response to an enquiery control code. | ||
628 | |||
629 | /*! | ||
630 | */ | ||
631 | |||
632 | void Vt102Emulation::reportCursorPosition() | ||
633 | { char tmp[20]; | ||
634 | sprintf(tmp,"\033[%d;%dR",scr->getCursorY()+1,scr->getCursorX()+1); | ||
635 | sendString(tmp); | ||
636 | } | ||
637 | |||
638 | /* | ||
639 | What follows here is rather obsolete and faked stuff. | ||
640 | The correspondent enquieries are neverthenless issued. | ||
641 | */ | ||
642 | |||
643 | /*! | ||
644 | */ | ||
645 | |||
646 | void Vt102Emulation::reportTerminalType() | ||
647 | { | ||
648 | //FIXME: should change? | ||
649 | if (getMode(MODE_Ansi)) | ||
650 | // sendString("\033[?1;2c"); // I'm a VT100 with AP0 //FIXME: send only in response to ^[[0c | ||
651 | sendString("\033[>0;115;0c"); // I'm a VT220 //FIXME: send only in response to ^[[>c | ||
652 | else | ||
653 | sendString("\033/Z"); // I'm a VT52 | ||
654 | } | ||
655 | |||
656 | void Vt102Emulation::reportTerminalParms(int p) | ||
657 | // DECREPTPARM | ||
658 | { char tmp[100]; | ||
659 | sprintf(tmp,"\033[%d;1;1;112;112;1;0x",p); // not really true. | ||
660 | sendString(tmp); | ||
661 | } | ||
662 | |||
663 | /*! | ||
664 | */ | ||
665 | |||
666 | void Vt102Emulation::reportStatus() | ||
667 | { | ||
668 | sendString("\033[0n"); //VT100. Device status report. 0 = Ready. | ||
669 | } | ||
670 | |||
671 | /*! | ||
672 | */ | ||
673 | |||
674 | #define ANSWER_BACK "" // This is really obsolete VT100 stuff. | ||
675 | |||
676 | void Vt102Emulation::reportAnswerBack() | ||
677 | { | ||
678 | sendString(ANSWER_BACK); | ||
679 | } | ||
680 | |||
681 | // Mouse Handling ---------------------------------------------------------- -- | ||
682 | |||
683 | /*! | ||
684 | Mouse clicks are possibly reported to the client | ||
685 | application if it has issued interest in them. | ||
686 | They are normally consumed by the widget for copy | ||
687 | and paste, but may be propagated from the widget | ||
688 | when gui->setMouseMarks is set via setMode(MODE_Mouse1000). | ||
689 | |||
690 | `x',`y' are 1-based. | ||
691 | `ev' (event) indicates the button pressed (0-2) | ||
692 | or a general mouse release (3). | ||
693 | */ | ||
694 | |||
695 | void Vt102Emulation::onMouse( int cb, int cx, int cy ) | ||
696 | { char tmp[20]; | ||
697 | if (!connected) return; | ||
698 | sprintf(tmp,"\033[M%c%c%c",cb+040,cx+040,cy+040); | ||
699 | sendString(tmp); | ||
700 | } | ||
701 | |||
702 | // Keyboard Handling ------------------------------------------------------- -- | ||
703 | |||
704 | #define encodeMode(M,B) BITS(B,getMode(M)) | ||
705 | #define encodeStat(M,B) BITS(B,((ev->state() & (M)) == (M))) | ||
706 | |||
707 | /* | ||
708 | Keyboard event handling has been simplified somewhat by pushing | ||
709 | the complications towards a configuration file [see KeyTrans class]. | ||
710 | */ | ||
711 | |||
712 | void Vt102Emulation::onKeyPress( QKeyEvent* ev ) | ||
713 | { | ||
714 | if (!connected) return; // someone else gets the keys | ||
715 | |||
716 | //printf("State/Key: 0x%04x 0x%04x (%d,%d)\n",ev->state(),ev->key(),ev->text().length(),ev->text().length()?ev->text().ascii()[0]:0); | ||
717 | |||
718 | // revert to non-history when typing | ||
719 | if (scr->getHistCursor() != scr->getHistLines()); | ||
720 | scr->setHistCursor(scr->getHistLines()); | ||
721 | |||
722 | // lookup in keyboard translation table ... | ||
723 | int cmd; const char* txt; int len; | ||
724 | if (keytrans->findEntry(ev->key(), encodeMode(MODE_NewLine , BITS_NewLine ) + // OLD, | ||
725 | encodeMode(MODE_Ansi , BITS_Ansi ) + // OBSOLETE, | ||
726 | encodeMode(MODE_AppCuKeys, BITS_AppCuKeys ) + // VT100 stuff | ||
727 | encodeStat(ControlButton , BITS_Control ) + | ||
728 | encodeStat(ShiftButton , BITS_Shift ) + | ||
729 | encodeStat(AltButton , BITS_Alt ), | ||
730 | &cmd, &txt, &len )) | ||
731 | //printf("cmd: %d, %s, %d\n",cmd,txt,len); | ||
732 | { | ||
733 | switch(cmd) // ... and execute if found. | ||
734 | { | ||
735 | case CMD_emitSelection : gui->insertSelection(); return; | ||
736 | case CMD_scrollPageUp : gui->scroll(-gui->lines()/2); return; | ||
737 | case CMD_scrollPageDown : gui->scroll(+gui->lines()/2); return; | ||
738 | case CMD_scrollLineUp : gui->scroll(-1 ); return; | ||
739 | case CMD_scrollLineDown : gui->scroll(+1 ); return; | ||
740 | case CMD_send : sendString( txt ); return; | ||
741 | case CMD_prevSession : emit prevSession(); return; | ||
742 | case CMD_nextSession : emit nextSession(); return; | ||
743 | } | ||
744 | } | ||
745 | // fall back handling | ||
746 | if (!ev->text().isEmpty()) | ||
747 | { | ||
748 | if (ev->state() & AltButton) sendString("\033"); // ESC, this is the ALT prefix | ||
749 | /// very hacky | ||
750 | if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='A')) sendString("\01"); | ||
751 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='B')) sendString("\02"); | ||
752 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='C')) sendString("\03"); | ||
753 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='D')) sendString("\04"); | ||
754 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='E')) sendString("\05"); | ||
755 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='F')) sendString("\06"); | ||
756 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='G')) sendString("\07"); | ||
757 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='H')) sendString("\010"); | ||
758 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='I')) sendString("\011"); | ||
759 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='J')) sendString("\012"); | ||
760 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='K')) sendString("\013"); | ||
761 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='L')) sendString("\014"); | ||
762 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='M')) sendString("\015"); | ||
763 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='N')) sendString("\016"); | ||
764 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='O')) sendString("\017"); | ||
765 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='P')) sendString("\020"); | ||
766 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Q')) sendString("\021"); | ||
767 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='R')) sendString("\022"); | ||
768 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='S')) sendString("\023"); | ||
769 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='T')) sendString("\024"); | ||
770 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='U')) sendString("\025"); | ||
771 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='V')) sendString("\026"); | ||
772 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='W')) sendString("\027"); | ||
773 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='X')) sendString("\030"); | ||
774 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Y')) sendString("\031"); | ||
775 | else if ((ev->state() & ControlButton) && (ev->text().upper().ascii()[0]=='Z')) sendString("\032"); | ||
776 | else | ||
777 | { | ||
778 | QCString s = codec->fromUnicode(ev->text()); // encode for application | ||
779 | sendString( s ); // we may well have s.length() > 1 | ||
780 | } | ||
781 | return; | ||
782 | } | ||
783 | } | ||
784 | |||
785 | /* ------------------------------------------------------------------------- */ | ||
786 | /* */ | ||
787 | /* VT100 Charsets */ | ||
788 | /* */ | ||
789 | /* ------------------------------------------------------------------------- */ | ||
790 | |||
791 | // Character Set Conversion ------------------------------------------------ -- | ||
792 | |||
793 | /* | ||
794 | The processing contains a VT100 specific code translation layer. | ||
795 | It's still in use and mainly responsible for the line drawing graphics. | ||
796 | |||
797 | These and some other glyphs are assigned to codes (0x5f-0xfe) | ||
798 | normally occupied by the latin letters. Since this codes also | ||
799 | appear within control sequences, the extra code conversion | ||
800 | does not permute with the tokenizer and is placed behind it | ||
801 | in the pipeline. It only applies to tokens, which represent | ||
802 | plain characters. | ||
803 | |||
804 | This conversion it eventually continued in TEWidget.C, since | ||
805 | it might involve VT100 enhanced fonts, which have these | ||
806 | particular glyphs allocated in (0x00-0x1f) in their code page. | ||
807 | */ | ||
808 | |||
809 | #define CHARSET charset[scr==screen[1]] | ||
810 | |||
811 | // Apply current character map. | ||
812 | |||
813 | unsigned short Vt102Emulation::applyCharset(unsigned short c) | ||
814 | { | ||
815 | if (CHARSET.graphic && 0x5f <= c && c <= 0x7e) return vt100_graphics[c-0x5f]; | ||
816 | if (CHARSET.pound && c == '#' ) return 0xa3; //This mode is obsolete | ||
817 | return c; | ||
818 | } | ||
819 | |||
820 | /* | ||
821 | "Charset" related part of the emulation state. | ||
822 | This configures the VT100 charset filter. | ||
823 | |||
824 | While most operation work on the current screen, | ||
825 | the following two are different. | ||
826 | */ | ||
827 | |||
828 | void Vt102Emulation::resetCharset(int scrno) | ||
829 | { | ||
830 | charset[scrno].cu_cs = 0; | ||
831 | strncpy(charset[scrno].charset,"BBBB",4); | ||
832 | charset[scrno].sa_graphic = FALSE; | ||
833 | charset[scrno].sa_pound = FALSE; | ||
834 | charset[scrno].graphic = FALSE; | ||
835 | charset[scrno].pound = FALSE; | ||
836 | } | ||
837 | |||
838 | /*! | ||
839 | */ | ||
840 | |||
841 | void Vt102Emulation::setCharset(int n, int cs) // on both screens. | ||
842 | { | ||
843 | charset[0].charset[n&3] = cs; useCharset(charset[0].cu_cs); | ||
844 | charset[1].charset[n&3] = cs; useCharset(charset[1].cu_cs); | ||
845 | } | ||
846 | |||
847 | /*! | ||
848 | */ | ||
849 | |||
850 | void Vt102Emulation::setAndUseCharset(int n, int cs) | ||
851 | { | ||
852 | CHARSET.charset[n&3] = cs; | ||
853 | useCharset(n&3); | ||
854 | } | ||
855 | |||
856 | /*! | ||
857 | */ | ||
858 | |||
859 | void Vt102Emulation::useCharset(int n) | ||
860 | { | ||
861 | CHARSET.cu_cs = n&3; | ||
862 | CHARSET.graphic = (CHARSET.charset[n&3] == '0'); | ||
863 | CHARSET.pound = (CHARSET.charset[n&3] == 'A'); //This mode is obsolete | ||
864 | } | ||
865 | |||
866 | /*! Save the cursor position and the rendition attribute settings. */ | ||
867 | |||
868 | void Vt102Emulation::saveCursor() | ||
869 | { | ||
870 | CHARSET.sa_graphic = CHARSET.graphic; | ||
871 | CHARSET.sa_pound = CHARSET.pound; //This mode is obsolete | ||
872 | // we are not clear about these | ||
873 | //sa_charset = charsets[cScreen->charset]; | ||
874 | //sa_charset_num = cScreen->charset; | ||
875 | scr->saveCursor(); | ||
876 | } | ||
877 | |||
878 | /*! Restore the cursor position and the rendition attribute settings. */ | ||
879 | |||
880 | void Vt102Emulation::restoreCursor() | ||
881 | { | ||
882 | CHARSET.graphic = CHARSET.sa_graphic; | ||
883 | CHARSET.pound = CHARSET.sa_pound; //This mode is obsolete | ||
884 | scr->restoreCursor(); | ||
885 | } | ||
886 | |||
887 | /* ------------------------------------------------------------------------- */ | ||
888 | /* */ | ||
889 | /* Mode Operations */ | ||
890 | /* */ | ||
891 | /* ------------------------------------------------------------------------- */ | ||
892 | |||
893 | /* | ||
894 | Some of the emulations state is either added to the state of the screens. | ||
895 | |||
896 | This causes some scoping problems, since different emulations choose to | ||
897 | located the mode either to the current screen or to both. | ||
898 | |||
899 | For strange reasons, the extend of the rendition attributes ranges over | ||
900 | all screens and not over the actual screen. | ||
901 | |||
902 | We decided on the precise precise extend, somehow. | ||
903 | */ | ||
904 | |||
905 | // "Mode" related part of the state. These are all booleans. | ||
906 | |||
907 | void Vt102Emulation::resetModes() | ||
908 | { | ||
909 | resetMode(MODE_Mouse1000); saveMode(MODE_Mouse1000); | ||
910 | resetMode(MODE_AppScreen); saveMode(MODE_AppScreen); | ||
911 | // here come obsolete modes | ||
912 | resetMode(MODE_AppCuKeys); saveMode(MODE_AppCuKeys); | ||
913 | resetMode(MODE_NewLine ); | ||
914 | setMode(MODE_Ansi ); | ||
915 | } | ||
916 | |||
917 | void Vt102Emulation::setMode(int m) | ||
918 | { | ||
919 | currParm.mode[m] = TRUE; | ||
920 | switch (m) | ||
921 | { | ||
922 | case MODE_Mouse1000 : //gui->setMouseMarks(FALSE); | ||
923 | break; | ||
924 | case MODE_AppScreen : screen[1]->clearSelection(); | ||
925 | screen[1]->clearEntireScreen(); | ||
926 | setScreen(1); | ||
927 | break; | ||
928 | } | ||
929 | if (m < MODES_SCREEN || m == MODE_NewLine) | ||
930 | { | ||
931 | screen[0]->setMode(m); | ||
932 | screen[1]->setMode(m); | ||
933 | } | ||
934 | } | ||
935 | |||
936 | void Vt102Emulation::resetMode(int m) | ||
937 | { | ||
938 | currParm.mode[m] = FALSE; | ||
939 | switch (m) | ||
940 | { | ||
941 | case MODE_Mouse1000 : //gui->setMouseMarks(TRUE); | ||
942 | break; | ||
943 | case MODE_AppScreen : screen[0]->clearSelection(); | ||
944 | setScreen(0); | ||
945 | break; | ||
946 | } | ||
947 | if (m < MODES_SCREEN || m == MODE_NewLine) | ||
948 | { | ||
949 | screen[0]->resetMode(m); | ||
950 | screen[1]->resetMode(m); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | void Vt102Emulation::saveMode(int m) | ||
955 | { | ||
956 | saveParm.mode[m] = currParm.mode[m]; | ||
957 | } | ||
958 | |||
959 | void Vt102Emulation::restoreMode(int m) | ||
960 | { | ||
961 | if(saveParm.mode[m]) setMode(m); else resetMode(m); | ||
962 | } | ||
963 | |||
964 | BOOL Vt102Emulation::getMode(int m) | ||
965 | { | ||
966 | return currParm.mode[m]; | ||
967 | } | ||
968 | |||
969 | void Vt102Emulation::setConnect(bool c) | ||
970 | { | ||
971 | EmulationLayer::setConnect(c); | ||
972 | if (c) | ||
973 | { // refresh mouse mode | ||
974 | if (getMode(MODE_Mouse1000)) | ||
975 | setMode(MODE_Mouse1000); | ||
976 | else | ||
977 | resetMode(MODE_Mouse1000); | ||
978 | } | ||
979 | } | ||
980 | |||
981 | /* ------------------------------------------------------------------------- */ | ||
982 | /* */ | ||
983 | /* Diagnostic */ | ||
984 | /* */ | ||
985 | /* ------------------------------------------------------------------------- */ | ||
986 | |||
987 | /*! shows the contents of the scan buffer. | ||
988 | |||
989 | This functions is used for diagnostics. It is called by \e ReportErrorToken | ||
990 | to inform about strings that cannot be decoded or handled by the emulation. | ||
991 | |||
992 | \sa ReportErrorToken | ||
993 | */ | ||
994 | |||
995 | /*! | ||
996 | */ | ||
997 | |||
998 | static void hexdump(int* s, int len) | ||
999 | { int i; | ||
1000 | for (i = 0; i < len; i++) | ||
1001 | { | ||
1002 | if (s[i] == '\\') | ||
1003 | printf("\\\\"); | ||
1004 | else | ||
1005 | if ((s[i]) > 32 && s[i] < 127) | ||
1006 | printf("%c",s[i]); | ||
1007 | else | ||
1008 | printf("\\%04x(hex)",s[i]); | ||
1009 | } | ||
1010 | } | ||
1011 | |||
1012 | void Vt102Emulation::scan_buffer_report() | ||
1013 | { | ||
1014 | if (ppos == 0 || ppos == 1 && (pbuf[0] & 0xff) >= 32) return; | ||
1015 | printf("token: "); hexdump(pbuf,ppos); printf("\n"); | ||
1016 | } | ||
1017 | |||
1018 | /*! | ||
1019 | */ | ||
1020 | |||
1021 | void Vt102Emulation::ReportErrorToken() | ||
1022 | { | ||
1023 | printf("undecodable "); scan_buffer_report(); | ||
1024 | } | ||
diff --git a/noncore/apps/opie-console/vt102emulation.h b/noncore/apps/opie-console/vt102emulation.h deleted file mode 100644 index 17ab449..0000000 --- a/noncore/apps/opie-console/vt102emulation.h +++ b/dev/null | |||
@@ -1,153 +0,0 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [TEmuVt102.h] X Terminal Emulation */ | ||
4 | /* */ | ||
5 | /* -------------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* -------------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | /* Ported embedded-konsole to opie-terminal */ | ||
19 | /* */ | ||
20 | /* Copyright (C) 2002 by opie developers <opie@handhelds.org> */ | ||
21 | /* */ | ||
22 | /* -------------------------------------------------------------------------- */ | ||
23 | |||
24 | #ifndef VT102EMU_H | ||
25 | #define VT102EMU_H | ||
26 | |||
27 | #include "widget_layer.h" | ||
28 | #include "screen.h" | ||
29 | #include "emulation_layer.h" | ||
30 | #include <qtimer.h> | ||
31 | #include <stdio.h> | ||
32 | |||
33 | // | ||
34 | |||
35 | #define MODE_AppScreen (MODES_SCREEN+0) | ||
36 | #define MODE_AppCuKeys (MODES_SCREEN+1) | ||
37 | #define MODE_AppKeyPad (MODES_SCREEN+2) | ||
38 | #define MODE_Mouse1000 (MODES_SCREEN+3) | ||
39 | #define MODE_Ansi (MODES_SCREEN+4) | ||
40 | #define MODE_total (MODES_SCREEN+5) | ||
41 | |||
42 | struct DECpar | ||
43 | { | ||
44 | BOOL mode[MODE_total]; | ||
45 | }; | ||
46 | |||
47 | struct CharCodes | ||
48 | { | ||
49 | // coding info | ||
50 | char charset[4]; // | ||
51 | int cu_cs; // actual charset. | ||
52 | bool graphic; // Some VT100 tricks | ||
53 | bool pound ; // Some VT100 tricks | ||
54 | bool sa_graphic; // saved graphic | ||
55 | bool sa_pound; // saved pound | ||
56 | }; | ||
57 | |||
58 | class Vt102Emulation: public EmulationLayer | ||
59 | { Q_OBJECT | ||
60 | |||
61 | public: | ||
62 | |||
63 | Vt102Emulation(WidgetLayer* gui); | ||
64 | ~Vt102Emulation(); | ||
65 | |||
66 | public slots: // signals incoming from Widget | ||
67 | |||
68 | void onKeyPress(QKeyEvent*); | ||
69 | void onMouse(int cb, int cx, int cy); | ||
70 | |||
71 | signals: | ||
72 | |||
73 | void changeTitle(int,const QString&); | ||
74 | void prevSession(); | ||
75 | void nextSession(); | ||
76 | |||
77 | public: | ||
78 | |||
79 | void reset(); | ||
80 | |||
81 | /** | ||
82 | * receive a char from IOLayer | ||
83 | */ | ||
84 | void onRcvChar(int cc); | ||
85 | |||
86 | /** | ||
87 | * sends a list of bytes to the IOLayer | ||
88 | */ | ||
89 | void sendString(const QByteArray&); | ||
90 | |||
91 | /** | ||
92 | * @deprecated use QByteArray instead | ||
93 | * see sendString() above | ||
94 | */ | ||
95 | void sendString(const char *); | ||
96 | |||
97 | public: | ||
98 | |||
99 | BOOL getMode (int m); | ||
100 | |||
101 | void setMode (int m); | ||
102 | void resetMode (int m); | ||
103 | void saveMode (int m); | ||
104 | void restoreMode(int m); | ||
105 | void resetModes(); | ||
106 | |||
107 | void setConnect(bool r); | ||
108 | |||
109 | private: | ||
110 | |||
111 | void resetToken(); | ||
112 | #define MAXPBUF 80 | ||
113 | void pushToToken(int cc); | ||
114 | int pbuf[MAXPBUF]; //FIXME: overflow? | ||
115 | int ppos; | ||
116 | #define MAXARGS 15 | ||
117 | void addDigit(int dig); | ||
118 | void addArgument(); | ||
119 | int argv[MAXARGS]; | ||
120 | int argc; | ||
121 | void initTokenizer(); | ||
122 | int tbl[256]; | ||
123 | |||
124 | void scan_buffer_report(); //FIXME: rename | ||
125 | void ReportErrorToken(); //FIXME: rename | ||
126 | |||
127 | void tau(int code, int p, int q); | ||
128 | void XtermHack(); | ||
129 | |||
130 | // | ||
131 | |||
132 | void reportTerminalType(); | ||
133 | void reportStatus(); | ||
134 | void reportAnswerBack(); | ||
135 | void reportCursorPosition(); | ||
136 | void reportTerminalParms(int p); | ||
137 | |||
138 | protected: | ||
139 | |||
140 | unsigned short applyCharset(unsigned short c); | ||
141 | void setCharset(int n, int cs); | ||
142 | void useCharset(int n); | ||
143 | void setAndUseCharset(int n, int cs); | ||
144 | void saveCursor(); | ||
145 | void restoreCursor(); | ||
146 | void resetCharset(int scrno); | ||
147 | CharCodes charset[2]; | ||
148 | |||
149 | DECpar currParm; | ||
150 | DECpar saveParm; | ||
151 | }; | ||
152 | |||
153 | #endif // ifndef ANSIEMU_H | ||
diff --git a/noncore/apps/opie-console/widget.cpp b/noncore/apps/opie-console/widget.cpp deleted file mode 100644 index 4a578be..0000000 --- a/noncore/apps/opie-console/widget.cpp +++ b/dev/null | |||
@@ -1,1278 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------ */ | ||
2 | /* */ | ||
3 | /* [TEWidget.C] Terminal Emulation Widget */ | ||
4 | /* */ | ||
5 | /* ------------------------------------------------------------------------ */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file is part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ------------------------------------------------------------------------ */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | |||
19 | /* ibot: | ||
20 | i changed | ||
21 | "currentSession->getEmulation()->sendString()" to | ||
22 | "currentSession->layer()->send()" | ||
23 | # this is not right! EmulationLayer should send it... | ||
24 | i changed all those to use emulationLayer()->send() instead | ||
25 | i had to create a QByteArray before... | ||
26 | |||
27 | TODO: | ||
28 | alter Widget to use only QByteArray, where applicable. | ||
29 | */ | ||
30 | |||
31 | |||
32 | |||
33 | /*! \class Widget | ||
34 | |||
35 | \brief Visible screen contents | ||
36 | |||
37 | This class is responsible to map the `image' of a terminal emulation to the | ||
38 | display. All the dependency of the emulation to a specific GUI or toolkit is | ||
39 | localized here. Further, this widget has no knowledge about being part of an | ||
40 | emulation, it simply work within the terminal emulation framework by exposing | ||
41 | size and key events and by being ordered to show a new image. | ||
42 | |||
43 | <ul> | ||
44 | <li> The internal image has the size of the widget (evtl. rounded up) | ||
45 | <li> The external image used in setImage can have any size. | ||
46 | <li> (internally) the external image is simply copied to the internal | ||
47 | when a setImage happens. During a resizeEvent no painting is done | ||
48 | a paintEvent is expected to follow anyway. | ||
49 | </ul> | ||
50 | |||
51 | \sa TEScreen \sa Emulation | ||
52 | */ | ||
53 | |||
54 | /* FIXME: | ||
55 | - 'image' may also be used uninitialized (it isn't in fact) in resizeEvent | ||
56 | - 'font_a' not used in mouse events | ||
57 | - add destructor | ||
58 | */ | ||
59 | |||
60 | /* TODO | ||
61 | - evtl. be sensitive to `paletteChange' while using default colors. | ||
62 | - set different 'rounding' styles? I.e. have a mode to show clipped chars? | ||
63 | */ | ||
64 | |||
65 | // #include "config.h" | ||
66 | #include "widget.h" | ||
67 | #include <qpe/config.h> | ||
68 | |||
69 | #include <qclipboard.h> | ||
70 | |||
71 | #include <stdio.h> | ||
72 | #include <stdlib.h> | ||
73 | #include <unistd.h> | ||
74 | #include <ctype.h> | ||
75 | #include <sys/stat.h> | ||
76 | #include <sys/types.h> | ||
77 | #include <signal.h> | ||
78 | |||
79 | #include <assert.h> | ||
80 | |||
81 | // #include "widget.moc" | ||
82 | //#include <kapp.h> | ||
83 | //#include <kcursor.h> | ||
84 | //#include <kurl.h> | ||
85 | //#include <kdebug.h> | ||
86 | //#include <klocale.h> | ||
87 | |||
88 | #define HERE printf("%s(%d): %s\n",__FILE__,__LINE__,__FUNCTION__) | ||
89 | #define HCNT(Name) // { static int cnt = 1; printf("%s(%d): %s %d\n",__FILE__,__LINE__,Name,cnt++); } | ||
90 | |||
91 | #define loc(X,Y) ((Y)*columns+(X)) | ||
92 | |||
93 | //FIXME: the rim should normally be 1, 0 only when running in full screen mode. | ||
94 | #define rimX 0 // left/right rim width | ||
95 | #define rimY 0 // top/bottom rim high | ||
96 | |||
97 | #define yMouseScroll 1 | ||
98 | // scroll increment used when dragging selection at top/bottom of window. | ||
99 | |||
100 | /* ------------------------------------------------------------------------- */ | ||
101 | /* */ | ||
102 | /* Colors */ | ||
103 | /* */ | ||
104 | /* ------------------------------------------------------------------------- */ | ||
105 | |||
106 | //FIXME: the default color table is in session.C now. | ||
107 | // We need a way to get rid of this one, here. | ||
108 | static const ColorEntry base_color_table[TABLE_COLORS] = | ||
109 | // The following are almost IBM standard color codes, with some slight | ||
110 | // gamma correction for the dim colors to compensate for bright X screens. | ||
111 | // It contains the 8 ansiterm/xterm colors in 2 intensities. | ||
112 | { | ||
113 | // Fixme: could add faint colors here, also. | ||
114 | // normal | ||
115 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 1, 0 ), // Dfore, Dback | ||
116 | ColorEntry(QColor(0x00,0x00,0x00), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0x18), 0, 0 ), // Black, Red | ||
117 | ColorEntry(QColor(0x18,0xB2,0x18), 0, 0 ), ColorEntry( QColor(0xB2,0x68,0x18), 0, 0 ), // Green, Yellow | ||
118 | ColorEntry(QColor(0x18,0x18,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), // Blue, Magenta | ||
119 | ColorEntry(QColor(0x18,0xB2,0xB2), 0, 0 ), ColorEntry( QColor(0xB2,0xB2,0xB2), 0, 0 ), // Cyan, White | ||
120 | // intensiv | ||
121 | ColorEntry(QColor(0x00,0x00,0x00), 0, 1 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 1, 0 ), | ||
122 | ColorEntry(QColor(0x68,0x68,0x68), 0, 0 ), ColorEntry( QColor(0xFF,0x54,0x54), 0, 0 ), | ||
123 | ColorEntry(QColor(0x54,0xFF,0x54), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0x54), 0, 0 ), | ||
124 | ColorEntry(QColor(0x54,0x54,0xFF), 0, 0 ), ColorEntry( QColor(0xB2,0x18,0xB2), 0, 0 ), | ||
125 | ColorEntry(QColor(0x54,0xFF,0xFF), 0, 0 ), ColorEntry( QColor(0xFF,0xFF,0xFF), 0, 0 ) | ||
126 | }; | ||
127 | |||
128 | /* Note that we use ANSI color order (bgr), while IBMPC color order is (rgb) | ||
129 | |||
130 | Code 0 1 2 3 4 5 6 7 | ||
131 | ----------- ------- ------- ------- ------- ------- ------- ------- ------- | ||
132 | ANSI (bgr) Black Red Green Yellow Blue Magenta Cyan White | ||
133 | IBMPC (rgb) Black Blue Green Cyan Red Magenta Yellow White | ||
134 | */ | ||
135 | |||
136 | QColor Widget::getDefaultBackColor() | ||
137 | { | ||
138 | return color_table[DEFAULT_BACK_COLOR].color; | ||
139 | } | ||
140 | |||
141 | const ColorEntry* Widget::getColorTable() const | ||
142 | { | ||
143 | return color_table; | ||
144 | } | ||
145 | |||
146 | const ColorEntry* Widget::getdefaultColorTable() const | ||
147 | { | ||
148 | return base_color_table; | ||
149 | } | ||
150 | |||
151 | |||
152 | const QPixmap *Widget::backgroundPixmap() | ||
153 | { | ||
154 | static QPixmap *bg = new QPixmap("~/qpim/main/pics/faded_bg.xpm"); | ||
155 | const QPixmap *pm = bg; | ||
156 | return pm; | ||
157 | } | ||
158 | |||
159 | void Widget::setColorTable(const ColorEntry table[]) | ||
160 | { | ||
161 | for (int i = 0; i < TABLE_COLORS; i++) color_table[i] = table[i]; | ||
162 | |||
163 | const QPixmap* pm = backgroundPixmap(); | ||
164 | if (!pm) setBackgroundColor(color_table[DEFAULT_BACK_COLOR].color); | ||
165 | update(); | ||
166 | } | ||
167 | |||
168 | //FIXME: add backgroundPixmapChanged. | ||
169 | |||
170 | /* ------------------------------------------------------------------------- */ | ||
171 | /* */ | ||
172 | /* Font */ | ||
173 | /* */ | ||
174 | /* ------------------------------------------------------------------------- */ | ||
175 | |||
176 | /* | ||
177 | The VT100 has 32 special graphical characters. The usual vt100 extended | ||
178 | xterm fonts have these at 0x00..0x1f. | ||
179 | |||
180 | QT's iso mapping leaves 0x00..0x7f without any changes. But the graphicals | ||
181 | come in here as proper unicode characters. | ||
182 | |||
183 | We treat non-iso10646 fonts as VT100 extended and do the requiered mapping | ||
184 | from unicode to 0x00..0x1f. The remaining translation is then left to the | ||
185 | QCodec. | ||
186 | */ | ||
187 | |||
188 | // assert for i in [0..31] : vt100extended(vt100_graphics[i]) == i. | ||
189 | |||
190 | unsigned short vt100_graphics[32] = | ||
191 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | ||
192 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | ||
193 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | ||
194 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | ||
195 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | ||
196 | }; | ||
197 | |||
198 | static QChar vt100extended(QChar c) | ||
199 | { | ||
200 | switch (c.unicode()) | ||
201 | { | ||
202 | case 0x25c6 : return 1; | ||
203 | case 0x2592 : return 2; | ||
204 | case 0x2409 : return 3; | ||
205 | case 0x240c : return 4; | ||
206 | case 0x240d : return 5; | ||
207 | case 0x240a : return 6; | ||
208 | case 0x00b0 : return 7; | ||
209 | case 0x00b1 : return 8; | ||
210 | case 0x2424 : return 9; | ||
211 | case 0x240b : return 10; | ||
212 | case 0x2518 : return 11; | ||
213 | case 0x2510 : return 12; | ||
214 | case 0x250c : return 13; | ||
215 | case 0x2514 : return 14; | ||
216 | case 0x253c : return 15; | ||
217 | case 0xf800 : return 16; | ||
218 | case 0xf801 : return 17; | ||
219 | case 0x2500 : return 18; | ||
220 | case 0xf803 : return 19; | ||
221 | case 0xf804 : return 20; | ||
222 | case 0x251c : return 21; | ||
223 | case 0x2524 : return 22; | ||
224 | case 0x2534 : return 23; | ||
225 | case 0x252c : return 24; | ||
226 | case 0x2502 : return 25; | ||
227 | case 0x2264 : return 26; | ||
228 | case 0x2265 : return 27; | ||
229 | case 0x03c0 : return 28; | ||
230 | case 0x2260 : return 29; | ||
231 | case 0x00a3 : return 30; | ||
232 | case 0x00b7 : return 31; | ||
233 | } | ||
234 | return c; | ||
235 | } | ||
236 | |||
237 | static QChar identicalMap(QChar c) | ||
238 | { | ||
239 | return c; | ||
240 | } | ||
241 | |||
242 | void Widget::fontChange(const QFont &) | ||
243 | { | ||
244 | QFontMetrics fm(font()); | ||
245 | font_h = fm.height(); | ||
246 | font_w = fm.maxWidth(); | ||
247 | font_a = fm.ascent(); | ||
248 | //printf("font_h: %d\n",font_h); | ||
249 | //printf("font_w: %d\n",font_w); | ||
250 | //printf("font_a: %d\n",font_a); | ||
251 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | ||
252 | //printf("rawname: %s\n",font().rawName().ascii()); | ||
253 | fontMap = | ||
254 | #if QT_VERSION < 300 | ||
255 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | ||
256 | ? vt100extended | ||
257 | : | ||
258 | #endif | ||
259 | identicalMap; | ||
260 | propagateSize(); | ||
261 | update(); | ||
262 | } | ||
263 | |||
264 | void Widget::setVTFont(const QFont& f) | ||
265 | { | ||
266 | QFrame::setFont(f); | ||
267 | } | ||
268 | |||
269 | QFont Widget::getVTFont() { | ||
270 | return font(); | ||
271 | } | ||
272 | |||
273 | void Widget::setFont(const QFont &) | ||
274 | { | ||
275 | // ignore font change request if not coming from konsole itself | ||
276 | } | ||
277 | |||
278 | /* ------------------------------------------------------------------------- */ | ||
279 | /* */ | ||
280 | /* Constructor / Destructor */ | ||
281 | /* */ | ||
282 | /* ------------------------------------------------------------------------- */ | ||
283 | |||
284 | Widget::Widget(QWidget *parent, const char *name) : QFrame(parent,name) | ||
285 | { | ||
286 | #ifndef QT_NO_CLIPBOARD | ||
287 | cb = QApplication::clipboard(); | ||
288 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
289 | this, SLOT(onClearSelection()) ); | ||
290 | #endif | ||
291 | |||
292 | scrollbar = new QScrollBar(this); | ||
293 | scrollbar->setCursor( arrowCursor ); | ||
294 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
295 | |||
296 | Config cfg("Konsole"); | ||
297 | cfg.setGroup("ScrollBar"); | ||
298 | switch( cfg.readNumEntry("Position",2)){ | ||
299 | case 0: | ||
300 | scrollLoc = SCRNONE; | ||
301 | break; | ||
302 | case 1: | ||
303 | scrollLoc = SCRLEFT; | ||
304 | break; | ||
305 | case 2: | ||
306 | scrollLoc = SCRRIGHT; | ||
307 | break; | ||
308 | }; | ||
309 | |||
310 | blinkT = new QTimer(this); | ||
311 | connect(blinkT, SIGNAL(timeout()), this, SLOT(blinkEvent())); | ||
312 | // blinking = FALSE; | ||
313 | blinking = TRUE; | ||
314 | |||
315 | resizing = FALSE; | ||
316 | actSel = 0; | ||
317 | image = 0; | ||
318 | lines = 1; | ||
319 | columns = 1; | ||
320 | font_w = 1; | ||
321 | font_h = 1; | ||
322 | font_a = 1; | ||
323 | word_selection_mode = FALSE; | ||
324 | |||
325 | setMouseMarks(TRUE); | ||
326 | setVTFont( QFont("fixed") ); | ||
327 | setColorTable(base_color_table); // init color table | ||
328 | |||
329 | qApp->installEventFilter( this ); //FIXME: see below | ||
330 | // KCursor::setAutoHideCursor( this, true ); | ||
331 | |||
332 | // Init DnD //////////////////////////////////////////////////////////////// | ||
333 | currentSession = NULL; | ||
334 | // setAcceptDrops(true); // attempt | ||
335 | // m_drop = new QPopupMenu(this); | ||
336 | // m_drop->insertItem( QString("Paste"), 0); | ||
337 | // m_drop->insertItem( QString("cd"), 1); | ||
338 | // connect(m_drop, SIGNAL(activated(int)), SLOT(drop_menu_activated(int))); | ||
339 | |||
340 | // we need focus so that the auto-hide cursor feature works | ||
341 | setFocus(); | ||
342 | setFocusPolicy( WheelFocus ); | ||
343 | } | ||
344 | |||
345 | //FIXME: make proper destructor | ||
346 | // Here's a start (David) | ||
347 | Widget::~Widget() | ||
348 | { | ||
349 | qApp->removeEventFilter( this ); | ||
350 | if (image) free(image); | ||
351 | } | ||
352 | |||
353 | /* ------------------------------------------------------------------------- */ | ||
354 | /* */ | ||
355 | /* Display Operations */ | ||
356 | /* */ | ||
357 | /* ------------------------------------------------------------------------- */ | ||
358 | |||
359 | /*! | ||
360 | attributed string draw primitive | ||
361 | */ | ||
362 | |||
363 | void Widget::drawAttrStr(QPainter &paint, QRect rect, | ||
364 | QString& str, Character attr, BOOL pm, BOOL clear) | ||
365 | { | ||
366 | if (pm && color_table[attr.b].transparent) | ||
367 | { | ||
368 | paint.setBackgroundMode( TransparentMode ); | ||
369 | if (clear) erase(rect); | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | if (blinking) | ||
374 | paint.fillRect(rect, color_table[attr.b].color); | ||
375 | else | ||
376 | { | ||
377 | paint.setBackgroundMode( OpaqueMode ); | ||
378 | paint.setBackgroundColor( color_table[attr.b].color ); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | if (color_table[attr.f].bold) | ||
383 | paint.setPen(QColor( 0x8F, 0x00, 0x00 )); | ||
384 | else | ||
385 | paint.setPen(color_table[attr.f].color); | ||
386 | |||
387 | paint.drawText(rect.x(),rect.y()+font_a, str); | ||
388 | |||
389 | if (attr.r & RE_UNDERLINE) | ||
390 | paint.drawLine(rect.left(), rect.y()+font_a+1, rect.right(),rect.y()+font_a+1 ); | ||
391 | } | ||
392 | |||
393 | /*! | ||
394 | The image can only be set completely. | ||
395 | |||
396 | The size of the new image may or may not match the size of the widget. | ||
397 | */ | ||
398 | |||
399 | void Widget::setImage(const Character* const newimg, int lines, int columns) | ||
400 | { int y,x,len; | ||
401 | const QPixmap* pm = backgroundPixmap(); | ||
402 | QPainter paint; | ||
403 | setUpdatesEnabled(FALSE); | ||
404 | paint.begin( this ); | ||
405 | HCNT("setImage"); | ||
406 | |||
407 | QPoint tL = contentsRect().topLeft(); | ||
408 | int tLx = tL.x(); | ||
409 | int tLy = tL.y(); | ||
410 | hasBlinker = FALSE; | ||
411 | |||
412 | int cf = -1; // undefined | ||
413 | int cb = -1; // undefined | ||
414 | int cr = -1; // undefined | ||
415 | |||
416 | int lins = QMIN(this->lines, QMAX(0,lines )); | ||
417 | int cols = QMIN(this->columns,QMAX(0,columns)); | ||
418 | QChar *disstrU = new QChar[cols]; | ||
419 | |||
420 | //{ static int cnt = 0; printf("setImage %d\n",cnt++); } | ||
421 | for (y = 0; y < lins; y++) | ||
422 | { | ||
423 | const Character* lcl = &image[y*this->columns]; | ||
424 | const Character* const ext = &newimg[y*columns]; | ||
425 | if (!resizing) // not while resizing, we're expecting a paintEvent | ||
426 | for (x = 0; x < cols; x++) | ||
427 | { | ||
428 | hasBlinker |= (ext[x].r & RE_BLINK); | ||
429 | if (ext[x] != lcl[x]) | ||
430 | { | ||
431 | cr = ext[x].r; | ||
432 | cb = ext[x].b; | ||
433 | if (ext[x].f != cf) cf = ext[x].f; | ||
434 | int lln = cols - x; | ||
435 | disstrU[0] = fontMap(ext[x+0].c); | ||
436 | for (len = 1; len < lln; len++) | ||
437 | { | ||
438 | if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr || | ||
439 | ext[x+len] == lcl[x+len] ) | ||
440 | break; | ||
441 | disstrU[len] = fontMap(ext[x+len].c); | ||
442 | } | ||
443 | QString unistr(disstrU,len); | ||
444 | drawAttrStr(paint, | ||
445 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | ||
446 | unistr, ext[x], pm != NULL, true); | ||
447 | x += len - 1; | ||
448 | } | ||
449 | } | ||
450 | // finally, make `image' become `newimg'. | ||
451 | memcpy((void*)lcl,(const void*)ext,cols*sizeof(Character)); | ||
452 | } | ||
453 | drawFrame( &paint ); | ||
454 | paint.end(); | ||
455 | setUpdatesEnabled(TRUE); | ||
456 | if ( hasBlinker && !blinkT->isActive()) blinkT->start(1000); // 1000 ms | ||
457 | if (!hasBlinker && blinkT->isActive()) { blinkT->stop(); blinking = FALSE; } | ||
458 | delete [] disstrU; | ||
459 | } | ||
460 | |||
461 | // paint Event //////////////////////////////////////////////////// | ||
462 | |||
463 | /*! | ||
464 | The difference of this routine vs. the `setImage' is, | ||
465 | that the drawing does not include a difference analysis | ||
466 | between the old and the new image. Instead, the internal | ||
467 | image is used and the painting bound by the PaintEvent box. | ||
468 | */ | ||
469 | |||
470 | void Widget::paintEvent( QPaintEvent* pe ) | ||
471 | { | ||
472 | |||
473 | //{ static int cnt = 0; printf("paint %d\n",cnt++); } | ||
474 | const QPixmap* pm = backgroundPixmap(); | ||
475 | QPainter paint; | ||
476 | setUpdatesEnabled(FALSE); | ||
477 | paint.begin( this ); | ||
478 | paint.setBackgroundMode( TransparentMode ); | ||
479 | HCNT("paintEvent"); | ||
480 | |||
481 | // Note that the actual widget size can be slightly larger | ||
482 | // that the image (the size is truncated towards the smaller | ||
483 | // number of characters in `resizeEvent'. The paint rectangle | ||
484 | // can thus be larger than the image, but less then the size | ||
485 | // of one character. | ||
486 | |||
487 | QRect rect = pe->rect().intersect(contentsRect()); | ||
488 | |||
489 | QPoint tL = contentsRect().topLeft(); | ||
490 | int tLx = tL.x(); | ||
491 | int tLy = tL.y(); | ||
492 | |||
493 | int lux = QMIN(columns-1, QMAX(0,(rect.left() - tLx - blX ) / font_w)); | ||
494 | int luy = QMIN(lines-1, QMAX(0,(rect.top() - tLy - bY ) / font_h)); | ||
495 | int rlx = QMIN(columns-1, QMAX(0,(rect.right() - tLx - blX ) / font_w)); | ||
496 | int rly = QMIN(lines-1, QMAX(0,(rect.bottom() - tLy - bY ) / font_h)); | ||
497 | |||
498 | /* | ||
499 | printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly, | ||
500 | rect.left(), rect.right(), rect.top(), rect.bottom()); | ||
501 | */ | ||
502 | |||
503 | // if (pm != NULL && color_table[image->b].transparent) | ||
504 | // erase(rect); | ||
505 | // BL: I have no idea why we need this, and it breaks the refresh. | ||
506 | |||
507 | QChar *disstrU = new QChar[columns]; | ||
508 | for (int y = luy; y <= rly; y++) | ||
509 | for (int x = lux; x <= rlx; x++) | ||
510 | { | ||
511 | int len = 1; | ||
512 | disstrU[0] = fontMap(image[loc(x,y)].c); | ||
513 | int cf = image[loc(x,y)].f; | ||
514 | int cb = image[loc(x,y)].b; | ||
515 | int cr = image[loc(x,y)].r; | ||
516 | while (x+len <= rlx && | ||
517 | image[loc(x+len,y)].f == cf && | ||
518 | image[loc(x+len,y)].b == cb && | ||
519 | image[loc(x+len,y)].r == cr ) | ||
520 | { | ||
521 | disstrU[len] = fontMap(image[loc(x+len,y)].c); | ||
522 | len += 1; | ||
523 | } | ||
524 | QString unistr(disstrU,len); | ||
525 | drawAttrStr(paint, | ||
526 | QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), | ||
527 | unistr, image[loc(x,y)], pm != NULL, false); | ||
528 | x += len - 1; | ||
529 | } | ||
530 | delete [] disstrU; | ||
531 | drawFrame( &paint ); | ||
532 | paint.end(); | ||
533 | setUpdatesEnabled(TRUE); | ||
534 | } | ||
535 | |||
536 | void Widget::blinkEvent() | ||
537 | { | ||
538 | blinking = !blinking; | ||
539 | repaint(FALSE); | ||
540 | } | ||
541 | |||
542 | /* ------------------------------------------------------------------------- */ | ||
543 | /* */ | ||
544 | /* Resizing */ | ||
545 | /* */ | ||
546 | /* ------------------------------------------------------------------------- */ | ||
547 | |||
548 | void Widget::resizeEvent(QResizeEvent* ev) | ||
549 | { | ||
550 | // printf("resize: %d,%d\n",ev->size().width(),ev->size().height()); | ||
551 | //printf("approx: %d,%d\n",ev->size().width()/font_w,ev->size().height()/font_h); | ||
552 | //printf("leaves: %d,%d\n",ev->size().width()%font_w,ev->size().height()%font_h); | ||
553 | //printf("curren: %d,%d\n",width(),height()); | ||
554 | HCNT("resizeEvent"); | ||
555 | |||
556 | // see comment in `paintEvent' concerning the rounding. | ||
557 | //FIXME: could make a routine here; check width(),height() | ||
558 | assert(ev->size().width() == width()); | ||
559 | assert(ev->size().height() == height()); | ||
560 | |||
561 | propagateSize(); | ||
562 | } | ||
563 | |||
564 | void Widget::propagateSize() | ||
565 | { | ||
566 | Character* oldimg = image; | ||
567 | int oldlin = lines; | ||
568 | int oldcol = columns; | ||
569 | makeImage(); | ||
570 | // we copy the old image to reduce flicker | ||
571 | int lins = QMIN(oldlin,lines); | ||
572 | int cols = QMIN(oldcol,columns); | ||
573 | if (oldimg) | ||
574 | { | ||
575 | for (int lin = 0; lin < lins; lin++) | ||
576 | memcpy((void*)&image[columns*lin], | ||
577 | (void*)&oldimg[oldcol*lin],cols*sizeof(Character)); | ||
578 | free(oldimg); //FIXME: try new,delete | ||
579 | } | ||
580 | else | ||
581 | clearImage(); | ||
582 | |||
583 | //NOTE: control flows from the back through the chest right into the eye. | ||
584 | // `emu' will call back via `setImage'. | ||
585 | |||
586 | resizing = TRUE; | ||
587 | emit changedImageSizeSignal(lines, columns); // expose resizeEvent | ||
588 | resizing = FALSE; | ||
589 | } | ||
590 | |||
591 | /* ------------------------------------------------------------------------- */ | ||
592 | /* */ | ||
593 | /* Scrollbar */ | ||
594 | /* */ | ||
595 | /* ------------------------------------------------------------------------- */ | ||
596 | |||
597 | void Widget::scrollChanged(int) | ||
598 | { | ||
599 | emit changedHistoryCursor(scrollbar->value()); //expose | ||
600 | } | ||
601 | |||
602 | void Widget::setScroll(int cursor, int slines) | ||
603 | { | ||
604 | disconnect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
605 | scrollbar->setRange(0,slines); | ||
606 | scrollbar->setSteps(1,lines); | ||
607 | scrollbar->setValue(cursor); | ||
608 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | ||
609 | } | ||
610 | |||
611 | void Widget::setScrollbarLocation(int loc) | ||
612 | { | ||
613 | if (scrollLoc == loc) return; // quickly | ||
614 | scrollLoc = loc; | ||
615 | propagateSize(); | ||
616 | update(); | ||
617 | } | ||
618 | |||
619 | /* ------------------------------------------------------------------------- */ | ||
620 | /* */ | ||
621 | /* Mouse */ | ||
622 | /* */ | ||
623 | /* ------------------------------------------------------------------------- */ | ||
624 | |||
625 | /*! | ||
626 | Three different operations can be performed using the mouse, and the | ||
627 | routines in this section serve all of them: | ||
628 | |||
629 | 1) The press/release events are exposed to the application | ||
630 | 2) Marking (press and move left button) and Pasting (press middle button) | ||
631 | 3) The right mouse button is used from the configuration menu | ||
632 | |||
633 | NOTE: During the marking process we attempt to keep the cursor within | ||
634 | the bounds of the text as being displayed by setting the mouse position | ||
635 | whenever the mouse has left the text area. | ||
636 | |||
637 | Two reasons to do so: | ||
638 | 1) QT does not allow the `grabMouse' to confine-to the Widget. | ||
639 | Thus a `XGrapPointer' would have to be used instead. | ||
640 | 2) Even if so, this would not help too much, since the text area | ||
641 | of the Widget is normally not identical with it's bounds. | ||
642 | |||
643 | The disadvantage of the current handling is, that the mouse can visibly | ||
644 | leave the bounds of the widget and is then moved back. Because of the | ||
645 | current construction, and the reasons mentioned above, we cannot do better | ||
646 | without changing the overall construction. | ||
647 | */ | ||
648 | |||
649 | /*! | ||
650 | */ | ||
651 | |||
652 | void Widget::mousePressEvent(QMouseEvent* ev) | ||
653 | { | ||
654 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | ||
655 | if ( !contentsRect().contains(ev->pos()) ) return; | ||
656 | QPoint tL = contentsRect().topLeft(); | ||
657 | int tLx = tL.x(); | ||
658 | int tLy = tL.y(); | ||
659 | |||
660 | word_selection_mode = FALSE; | ||
661 | |||
662 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | ||
663 | if ( ev->button() == LeftButton) | ||
664 | { | ||
665 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
666 | |||
667 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | ||
668 | |||
669 | if (mouse_marks || (ev->state() & ShiftButton)) | ||
670 | { | ||
671 | emit clearSelectionSignal(); | ||
672 | iPntSel = pntSel = pos; | ||
673 | actSel = 1; // left mouse button pressed but nothing selected yet. | ||
674 | grabMouse( /*crossCursor*/ ); // handle with care! | ||
675 | } | ||
676 | else | ||
677 | { | ||
678 | emit mouseSignal( 0, pos.x() + 1, pos.y() + 1 ); // left button | ||
679 | } | ||
680 | } | ||
681 | if ( ev->button() == MidButton ) | ||
682 | { | ||
683 | emitSelection(); | ||
684 | } | ||
685 | if ( ev->button() == RightButton ) // Configure | ||
686 | { | ||
687 | emit configureRequest( this, ev->state()&(ShiftButton|ControlButton), ev->x(), ev->y() ); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | void Widget::mouseMoveEvent(QMouseEvent* ev) | ||
692 | { | ||
693 | // for auto-hiding the cursor, we need mouseTracking | ||
694 | if (ev->state() == NoButton ) return; | ||
695 | |||
696 | if (actSel == 0) return; | ||
697 | |||
698 | // don't extend selection while pasting | ||
699 | if (ev->state() & MidButton) return; | ||
700 | |||
701 | //if ( !contentsRect().contains(ev->pos()) ) return; | ||
702 | QPoint tL = contentsRect().topLeft(); | ||
703 | int tLx = tL.x(); | ||
704 | int tLy = tL.y(); | ||
705 | int scroll = scrollbar->value(); | ||
706 | |||
707 | // we're in the process of moving the mouse with the left button pressed | ||
708 | // the mouse cursor will kept catched within the bounds of the text in | ||
709 | // this widget. | ||
710 | |||
711 | // Adjust position within text area bounds. See FIXME above. | ||
712 | QPoint pos = ev->pos(); | ||
713 | if ( pos.x() < tLx+blX ) pos.setX( tLx+blX ); | ||
714 | if ( pos.x() > tLx+blX+columns*font_w-1 ) pos.setX( tLx+blX+columns*font_w ); | ||
715 | if ( pos.y() < tLy+bY ) pos.setY( tLy+bY ); | ||
716 | if ( pos.y() > tLy+bY+lines*font_h-1 ) pos.setY( tLy+bY+lines*font_h-1 ); | ||
717 | // check if we produce a mouse move event by this | ||
718 | if ( pos != ev->pos() ) cursor().setPos(mapToGlobal(pos)); | ||
719 | |||
720 | if ( pos.y() == tLy+bY+lines*font_h-1 ) | ||
721 | { | ||
722 | scrollbar->setValue(scrollbar->value()+yMouseScroll); // scrollforward | ||
723 | } | ||
724 | if ( pos.y() == tLy+bY ) | ||
725 | { | ||
726 | scrollbar->setValue(scrollbar->value()-yMouseScroll); // scrollback | ||
727 | } | ||
728 | |||
729 | QPoint here = QPoint((pos.x()-tLx-blX)/font_w,(pos.y()-tLy-bY)/font_h); | ||
730 | QPoint ohere; | ||
731 | bool swapping = FALSE; | ||
732 | |||
733 | if ( word_selection_mode ) | ||
734 | { | ||
735 | // Extend to word boundaries | ||
736 | int i; | ||
737 | int selClass; | ||
738 | |||
739 | bool left_not_right = ( here.y() < iPntSel.y() || | ||
740 | here.y() == iPntSel.y() && here.x() < iPntSel.x() ); | ||
741 | bool old_left_not_right = ( pntSel.y() < iPntSel.y() || | ||
742 | pntSel.y() == iPntSel.y() && pntSel.x() < iPntSel.x() ); | ||
743 | swapping = left_not_right != old_left_not_right; | ||
744 | |||
745 | // Find left (left_not_right ? from here : from start) | ||
746 | QPoint left = left_not_right ? here : iPntSel; | ||
747 | i = loc(left.x(),left.y()); | ||
748 | selClass = charClass(image[i].c); | ||
749 | while ( left.x() > 0 && charClass(image[i-1].c) == selClass ) | ||
750 | { i--; left.rx()--; } | ||
751 | |||
752 | // Find left (left_not_right ? from start : from here) | ||
753 | QPoint right = left_not_right ? iPntSel : here; | ||
754 | i = loc(right.x(),right.y()); | ||
755 | selClass = charClass(image[i].c); | ||
756 | while ( right.x() < columns-1 && charClass(image[i+1].c) == selClass ) | ||
757 | { i++; right.rx()++; } | ||
758 | |||
759 | // Pick which is start (ohere) and which is extension (here) | ||
760 | if ( left_not_right ) | ||
761 | { | ||
762 | here = left; ohere = right; | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | here = right; ohere = left; | ||
767 | } | ||
768 | } | ||
769 | |||
770 | if (here == pntSel && scroll == scrollbar->value()) return; // not moved | ||
771 | |||
772 | if ( word_selection_mode ) { | ||
773 | if ( actSel < 2 || swapping ) { | ||
774 | emit beginSelectionSignal( ohere.x(), ohere.y() ); | ||
775 | } | ||
776 | } else if ( actSel < 2 ) { | ||
777 | emit beginSelectionSignal( pntSel.x(), pntSel.y() ); | ||
778 | } | ||
779 | |||
780 | actSel = 2; // within selection | ||
781 | pntSel = here; | ||
782 | emit extendSelectionSignal( here.x(), here.y() ); | ||
783 | } | ||
784 | |||
785 | void Widget::mouseReleaseEvent(QMouseEvent* ev) | ||
786 | { | ||
787 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | ||
788 | if ( ev->button() == LeftButton) | ||
789 | { | ||
790 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | ||
791 | preserve_line_breaks = TRUE; | ||
792 | actSel = 0; | ||
793 | |||
794 | //FIXME: emits a release event even if the mouse is | ||
795 | // outside the range. The procedure used in `mouseMoveEvent' | ||
796 | // applies here, too. | ||
797 | |||
798 | QPoint tL = contentsRect().topLeft(); | ||
799 | int tLx = tL.x(); | ||
800 | int tLy = tL.y(); | ||
801 | |||
802 | if (!mouse_marks && !(ev->state() & ShiftButton)) | ||
803 | emit mouseSignal( 3, // release | ||
804 | (ev->x()-tLx-blX)/font_w + 1, | ||
805 | (ev->y()-tLy-bY)/font_h + 1 ); | ||
806 | releaseMouse(); | ||
807 | } | ||
808 | } | ||
809 | |||
810 | void Widget::mouseDoubleClickEvent(QMouseEvent* ev) | ||
811 | { | ||
812 | if ( ev->button() != LeftButton) return; | ||
813 | |||
814 | QPoint tL = contentsRect().topLeft(); | ||
815 | int tLx = tL.x(); | ||
816 | int tLy = tL.y(); | ||
817 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
818 | |||
819 | // pass on double click as two clicks. | ||
820 | if (!mouse_marks && !(ev->state() & ShiftButton)) | ||
821 | { | ||
822 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | ||
823 | emit mouseSignal( 3, pos.x()+1, pos.y()+1 ); // release | ||
824 | emit mouseSignal( 0, pos.x()+1, pos.y()+1 ); // left button | ||
825 | return; | ||
826 | } | ||
827 | |||
828 | |||
829 | emit clearSelectionSignal(); | ||
830 | QPoint bgnSel = pos; | ||
831 | QPoint endSel = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | ||
832 | int i = loc(bgnSel.x(),bgnSel.y()); | ||
833 | iPntSel = bgnSel; | ||
834 | |||
835 | word_selection_mode = TRUE; | ||
836 | |||
837 | // find word boundaries... | ||
838 | int selClass = charClass(image[i].c); | ||
839 | { | ||
840 | // set the start... | ||
841 | int x = bgnSel.x(); | ||
842 | while ( x > 0 && charClass(image[i-1].c) == selClass ) | ||
843 | { i--; x--; } | ||
844 | bgnSel.setX(x); | ||
845 | emit beginSelectionSignal( bgnSel.x(), bgnSel.y() ); | ||
846 | |||
847 | // set the end... | ||
848 | i = loc( endSel.x(), endSel.y() ); | ||
849 | x = endSel.x(); | ||
850 | while( x < columns-1 && charClass(image[i+1].c) == selClass ) | ||
851 | { i++; x++ ; } | ||
852 | endSel.setX(x); | ||
853 | actSel = 2; // within selection | ||
854 | emit extendSelectionSignal( endSel.x(), endSel.y() ); | ||
855 | emit endSelectionSignal(preserve_line_breaks); | ||
856 | preserve_line_breaks = TRUE; | ||
857 | } | ||
858 | } | ||
859 | |||
860 | void Widget::focusInEvent( QFocusEvent * ) | ||
861 | { | ||
862 | |||
863 | // do nothing, to prevent repainting | ||
864 | } | ||
865 | |||
866 | |||
867 | void Widget::focusOutEvent( QFocusEvent * ) | ||
868 | { | ||
869 | // do nothing, to prevent repainting | ||
870 | } | ||
871 | |||
872 | bool Widget::focusNextPrevChild( bool next ) | ||
873 | { | ||
874 | if (next) | ||
875 | return false; // This disables changing the active part in konqueror | ||
876 | // when pressing Tab | ||
877 | return QFrame::focusNextPrevChild( next ); | ||
878 | } | ||
879 | |||
880 | |||
881 | int Widget::charClass(char ch) const | ||
882 | { | ||
883 | // This might seem like overkill, but imagine if ch was a Unicode | ||
884 | // character (Qt 2.0 QChar) - it might then be sensible to separate | ||
885 | // the different language ranges, etc. | ||
886 | |||
887 | if ( isspace(ch) ) return ' '; | ||
888 | |||
889 | static const char *word_characters = ":@-./_~"; | ||
890 | if ( isalnum(ch) || strchr(word_characters, ch) ) | ||
891 | return 'a'; | ||
892 | |||
893 | // Everything else is weird | ||
894 | return 1; | ||
895 | } | ||
896 | |||
897 | void Widget::setMouseMarks(bool on) | ||
898 | { | ||
899 | mouse_marks = on; | ||
900 | setCursor( mouse_marks ? ibeamCursor : arrowCursor ); | ||
901 | } | ||
902 | |||
903 | /* ------------------------------------------------------------------------- */ | ||
904 | /* */ | ||
905 | /* Clipboard */ | ||
906 | /* */ | ||
907 | /* ------------------------------------------------------------------------- */ | ||
908 | |||
909 | #undef KeyPress | ||
910 | |||
911 | void Widget::emitSelection() | ||
912 | // Paste Clipboard by simulating keypress events | ||
913 | { | ||
914 | #ifndef QT_NO_CLIPBOARD | ||
915 | QString text = QApplication::clipboard()->text(); | ||
916 | if ( ! text.isNull() ) | ||
917 | { | ||
918 | text.replace(QRegExp("\n"), "\r"); | ||
919 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | ||
920 | emit keyPressedSignal(&e); // expose as a big fat keypress event | ||
921 | emit clearSelectionSignal(); | ||
922 | } | ||
923 | #endif | ||
924 | } | ||
925 | |||
926 | void Widget::emitText(QString text) | ||
927 | { | ||
928 | QKeyEvent e(QEvent::KeyPress, 0, -1, 0, text); | ||
929 | emit keyPressedSignal(&e); // expose as a big fat keypress event | ||
930 | } | ||
931 | |||
932 | void Widget::pasteClipboard( ) | ||
933 | { | ||
934 | emitSelection(); | ||
935 | } | ||
936 | |||
937 | void Widget::setSelection(const QString& t) | ||
938 | { | ||
939 | #ifndef QT_NO_CLIPBOARD | ||
940 | // Disconnect signal while WE set the clipboard | ||
941 | QObject *cb = QApplication::clipboard(); | ||
942 | QObject::disconnect( cb, SIGNAL(dataChanged()), | ||
943 | this, SLOT(onClearSelection()) ); | ||
944 | |||
945 | QApplication::clipboard()->setText(t); | ||
946 | |||
947 | QObject::connect( cb, SIGNAL(dataChanged()), | ||
948 | this, SLOT(onClearSelection()) ); | ||
949 | #endif | ||
950 | } | ||
951 | |||
952 | void Widget::onClearSelection() | ||
953 | { | ||
954 | emit clearSelectionSignal(); | ||
955 | } | ||
956 | |||
957 | /* ------------------------------------------------------------------------- */ | ||
958 | /* */ | ||
959 | /* Keyboard */ | ||
960 | /* */ | ||
961 | /* ------------------------------------------------------------------------- */ | ||
962 | |||
963 | //FIXME: an `eventFilter' has been installed instead of a `keyPressEvent' | ||
964 | // due to a bug in `QT' or the ignorance of the author to prevent | ||
965 | // repaint events being emitted to the screen whenever one leaves | ||
966 | // or reenters the screen to/from another application. | ||
967 | // | ||
968 | // Troll says one needs to change focusInEvent() and focusOutEvent(), | ||
969 | // which would also let you have an in-focus cursor and an out-focus | ||
970 | // cursor like xterm does. | ||
971 | |||
972 | // for the auto-hide cursor feature, I added empty focusInEvent() and | ||
973 | // focusOutEvent() so that update() isn't called. | ||
974 | // For auto-hide, we need to get keypress-events, but we only get them when | ||
975 | // we have focus. | ||
976 | |||
977 | void Widget::doScroll(int lines) | ||
978 | { | ||
979 | scrollbar->setValue(scrollbar->value()+lines); | ||
980 | } | ||
981 | |||
982 | bool Widget::eventFilter( QObject *obj, QEvent *e ) | ||
983 | { | ||
984 | if ( (e->type() == QEvent::Accel || | ||
985 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
986 | static_cast<QKeyEvent *>( e )->ignore(); | ||
987 | return true; | ||
988 | } | ||
989 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
990 | return FALSE; // not us | ||
991 | if ( e->type() == QEvent::Wheel) { | ||
992 | QApplication::sendEvent(scrollbar, e); | ||
993 | } | ||
994 | |||
995 | #ifdef FAKE_CTRL_AND_ALT | ||
996 | static bool control = FALSE; | ||
997 | static bool alt = FALSE; | ||
998 | bool dele=FALSE; | ||
999 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
1000 | QKeyEvent* ke = (QKeyEvent*)e; | ||
1001 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
1002 | switch (ke->key()) { | ||
1003 | case Key_F9: // let this be "Control" | ||
1004 | control = keydown; | ||
1005 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
1006 | dele=TRUE; | ||
1007 | break; | ||
1008 | case Key_F13: // let this be "Alt" | ||
1009 | alt = keydown; | ||
1010 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
1011 | dele=TRUE; | ||
1012 | break; | ||
1013 | default: | ||
1014 | if ( control ) { | ||
1015 | int a = toupper(ke->ascii())-64; | ||
1016 | if ( a >= 0 && a < ' ' ) { | ||
1017 | e = new QKeyEvent(e->type(), ke->key(), | ||
1018 | a, ke->state()|ControlButton, QChar(a,0)); | ||
1019 | dele=TRUE; | ||
1020 | } | ||
1021 | } | ||
1022 | if ( alt ) { | ||
1023 | e = new QKeyEvent(e->type(), ke->key(), | ||
1024 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
1025 | dele=TRUE; | ||
1026 | } | ||
1027 | } | ||
1028 | } | ||
1029 | #endif | ||
1030 | |||
1031 | if ( e->type() == QEvent::KeyPress ) { | ||
1032 | QKeyEvent* ke = (QKeyEvent*)e; | ||
1033 | actSel=0; // Key stroke implies a screen update, so Widget won't | ||
1034 | // know where the current selection is. | ||
1035 | |||
1036 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
1037 | emitText("\\"); // expose | ||
1038 | } else | ||
1039 | emit keyPressedSignal(ke); // expose | ||
1040 | ke->accept(); | ||
1041 | #ifdef FAKE_CTRL_AND_ALT | ||
1042 | if ( dele ) delete e; | ||
1043 | #endif | ||
1044 | return true; // stop the event | ||
1045 | } | ||
1046 | if ( e->type() == QEvent::Enter ) { | ||
1047 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | ||
1048 | this, SLOT(onClearSelection()) ); | ||
1049 | } | ||
1050 | if ( e->type() == QEvent::Leave ) { | ||
1051 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
1052 | this, SLOT(onClearSelection()) ); | ||
1053 | } | ||
1054 | return QFrame::eventFilter( obj, e ); | ||
1055 | } | ||
1056 | |||
1057 | /* ------------------------------------------------------------------------- */ | ||
1058 | /* */ | ||
1059 | /* Frame */ | ||
1060 | /* */ | ||
1061 | /* ------------------------------------------------------------------------- */ | ||
1062 | |||
1063 | void Widget::frameChanged() | ||
1064 | { | ||
1065 | propagateSize(); | ||
1066 | update(); | ||
1067 | } | ||
1068 | |||
1069 | /* ------------------------------------------------------------------------- */ | ||
1070 | /* */ | ||
1071 | /* Sound */ | ||
1072 | /* */ | ||
1073 | /* ------------------------------------------------------------------------- */ | ||
1074 | |||
1075 | void Widget::Bell() | ||
1076 | { | ||
1077 | QApplication::beep(); | ||
1078 | } | ||
1079 | |||
1080 | /* ------------------------------------------------------------------------- */ | ||
1081 | /* */ | ||
1082 | /* Auxiluary */ | ||
1083 | /* */ | ||
1084 | /* ------------------------------------------------------------------------- */ | ||
1085 | |||
1086 | void Widget::clearImage() | ||
1087 | // initialize the image | ||
1088 | // for internal use only | ||
1089 | { | ||
1090 | for (int y = 0; y < lines; y++) | ||
1091 | for (int x = 0; x < columns; x++) | ||
1092 | { | ||
1093 | image[loc(x,y)].c = 0xff; //' '; | ||
1094 | image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; | ||
1095 | image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; | ||
1096 | image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; | ||
1097 | } | ||
1098 | } | ||
1099 | |||
1100 | // Create Image /////////////////////////////////////////////////////// | ||
1101 | |||
1102 | void Widget::calcGeometry() | ||
1103 | { | ||
1104 | //FIXME: set rimX == rimY == 0 when running in full screen mode. | ||
1105 | |||
1106 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | ||
1107 | contentsRect().height()); | ||
1108 | switch(scrollLoc) | ||
1109 | { | ||
1110 | case SCRNONE : | ||
1111 | columns = ( contentsRect().width() - 2 * rimX ) / font_w; | ||
1112 | blX = (contentsRect().width() - (columns*font_w) ) / 2; | ||
1113 | brX = blX; | ||
1114 | scrollbar->hide(); | ||
1115 | break; | ||
1116 | case SCRLEFT : | ||
1117 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1118 | brX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1119 | blX = brX + scrollbar->width(); | ||
1120 | scrollbar->move(contentsRect().topLeft()); | ||
1121 | scrollbar->show(); | ||
1122 | break; | ||
1123 | case SCRRIGHT: | ||
1124 | columns = ( contentsRect().width() - 2 * rimX - scrollbar->width()) / font_w; | ||
1125 | blX = (contentsRect().width() - (columns*font_w) - scrollbar->width() ) / 2; | ||
1126 | brX = blX; | ||
1127 | scrollbar->move(contentsRect().topRight() - QPoint(scrollbar->width()-1,0)); | ||
1128 | scrollbar->show(); | ||
1129 | break; | ||
1130 | } | ||
1131 | //FIXME: support 'rounding' styles | ||
1132 | lines = ( contentsRect().height() - 2 * rimY ) / font_h; | ||
1133 | bY = (contentsRect().height() - (lines *font_h)) / 2; | ||
1134 | } | ||
1135 | |||
1136 | void Widget::makeImage() | ||
1137 | //FIXME: rename 'calcGeometry? | ||
1138 | { | ||
1139 | calcGeometry(); | ||
1140 | image = (Character*) malloc(lines*columns*sizeof(Character)); | ||
1141 | clearImage(); | ||
1142 | } | ||
1143 | |||
1144 | // calculate the needed size | ||
1145 | QSize Widget::calcSize(int cols, int lins) const | ||
1146 | { | ||
1147 | int frw = width() - contentsRect().width(); | ||
1148 | int frh = height() - contentsRect().height(); | ||
1149 | int scw = (scrollLoc==SCRNONE?0:scrollbar->width()); | ||
1150 | return QSize( font_w*cols + 2*rimX + frw + scw, font_h*lins + 2*rimY + frh ); | ||
1151 | } | ||
1152 | |||
1153 | QSize Widget::sizeHint() const | ||
1154 | { | ||
1155 | return size(); | ||
1156 | } | ||
1157 | |||
1158 | void Widget::styleChange(QStyle &) | ||
1159 | { | ||
1160 | propagateSize(); | ||
1161 | } | ||
1162 | |||
1163 | #ifndef QT_NO_DRAGANDDROP | ||
1164 | |||
1165 | /* --------------------------------------------------------------------- */ | ||
1166 | /* */ | ||
1167 | /* Drag & Drop */ | ||
1168 | /* */ | ||
1169 | /* --------------------------------------------------------------------- */ | ||
1170 | |||
1171 | |||
1172 | void Widget::dragEnterEvent(QDragEnterEvent* e) | ||
1173 | { | ||
1174 | e->accept(QTextDrag::canDecode(e) || | ||
1175 | QUriDrag::canDecode(e)); | ||
1176 | } | ||
1177 | |||
1178 | void Widget::dropEvent(QDropEvent* event) | ||
1179 | { | ||
1180 | // The current behaviour when url(s) are dropped is | ||
1181 | // * if there is only ONE url and if it's a LOCAL one, ask for paste or cd | ||
1182 | // * in all other cases, just paste | ||
1183 | // (for non-local ones, or for a list of URLs, 'cd' is nonsense) | ||
1184 | QStrList strlist; | ||
1185 | int file_count = 0; | ||
1186 | dropText = ""; | ||
1187 | bool bPopup = true; | ||
1188 | |||
1189 | if(QUriDrag::decode(event, strlist)) { | ||
1190 | if (strlist.count()) { | ||
1191 | for(const char* p = strlist.first(); p; p = strlist.next()) { | ||
1192 | if(file_count++ > 0) { | ||
1193 | dropText += " "; | ||
1194 | bPopup = false; // more than one file, don't popup | ||
1195 | } | ||
1196 | |||
1197 | /* | ||
1198 | KURL url(p); | ||
1199 | if (url.isLocalFile()) { | ||
1200 | dropText += url.path(); // local URL : remove protocol | ||
1201 | } | ||
1202 | else { | ||
1203 | dropText += url.prettyURL(); | ||
1204 | bPopup = false; // a non-local file, don't popup | ||
1205 | } | ||
1206 | */ | ||
1207 | |||
1208 | } | ||
1209 | |||
1210 | if (bPopup) | ||
1211 | // m_drop->popup(pos() + event->pos()); | ||
1212 | m_drop->popup(mapToGlobal(event->pos())); | ||
1213 | else | ||
1214 | { | ||
1215 | if (currentSession) { | ||
1216 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1217 | QByteArray tmp; | ||
1218 | // ibot: this should be pretty wrong... | ||
1219 | // now it sends to the right layer | ||
1220 | currentSession-> emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1221 | } | ||
1222 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | ||
1223 | } | ||
1224 | } | ||
1225 | } | ||
1226 | else if(QTextDrag::decode(event, dropText)) { | ||
1227 | // kdDebug() << "Drop:" << dropText.local8Bit() << "\n"; | ||
1228 | if (currentSession) { | ||
1229 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1230 | QByteArray tmp; | ||
1231 | currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1232 | } | ||
1233 | // Paste it | ||
1234 | } | ||
1235 | } | ||
1236 | #endif | ||
1237 | |||
1238 | |||
1239 | void Widget::drop_menu_activated(int item) | ||
1240 | { | ||
1241 | #ifndef QT_NO_DRAGANDDROP | ||
1242 | QByteArray tmp; | ||
1243 | switch (item) | ||
1244 | { | ||
1245 | case 0: // paste | ||
1246 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1247 | currentSession->emulationLayer()->send( tmp.setRawData( dropText.local8Bit())); | ||
1248 | |||
1249 | // KWM::activate((Window)this->winId()); | ||
1250 | break; | ||
1251 | case 1: // cd ... | ||
1252 | //currentSession->getEmulation()->sendString("cd "); | ||
1253 | tmp.setRawData( "cd " ); | ||
1254 | currentSession->emulationLayer()->send( tmp ); | ||
1255 | struct stat statbuf; | ||
1256 | if ( ::stat( QFile::encodeName( dropText ), &statbuf ) == 0 ) | ||
1257 | { | ||
1258 | if ( !S_ISDIR(statbuf.st_mode) ) | ||
1259 | { | ||
1260 | /* | ||
1261 | KURL url; | ||
1262 | url.setPath( dropText ); | ||
1263 | dropText = url.directory( true, false ); // remove filename | ||
1264 | */ | ||
1265 | } | ||
1266 | } | ||
1267 | dropText.replace(QRegExp(" "), "\\ "); // escape spaces | ||
1268 | QByteArray tmp2; | ||
1269 | tmp.setRawDate( dropText.local8Bit() + "\n" ); | ||
1270 | //currentSession->getEmulation()->sendString(dropText.local8Bit()); | ||
1271 | //currentSession->getEmulation()->sendString("\n"); | ||
1272 | currentSession->emulationLayer()->send( tmp ); | ||
1273 | // KWM::activate((Window)this->winId()); | ||
1274 | break; | ||
1275 | } | ||
1276 | #endif | ||
1277 | } | ||
1278 | |||
diff --git a/noncore/apps/opie-console/widget.h b/noncore/apps/opie-console/widget.h deleted file mode 100644 index cfd709c..0000000 --- a/noncore/apps/opie-console/widget.h +++ b/dev/null | |||
@@ -1,213 +0,0 @@ | |||
1 | /* ----------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [widget.h] Terminal Emulation Widget */ | ||
4 | /* */ | ||
5 | /* ----------------------------------------------------------------------- */ | ||
6 | /* */ | ||
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | ||
8 | /* */ | ||
9 | /* This file was part of Konsole - an X terminal for KDE */ | ||
10 | /* */ | ||
11 | /* ----------------------------------------------------------------------- */ | ||
12 | /* */ | ||
13 | /* Ported Konsole to Qt/Embedded */ | ||
14 | /* */ | ||
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
16 | /* */ | ||
17 | /* -------------------------------------------------------------------------- */ | ||
18 | /* */ | ||
19 | /* modified to suit opie-console */ | ||
20 | /* */ | ||
21 | /* Copyright (c) 2002 by opie developers <opie@handhelds.org> */ | ||
22 | /* */ | ||
23 | /* ------------------------------------------------------------------------ */ | ||
24 | |||
25 | // ibot: TODO * | ||
26 | |||
27 | #ifndef WIDGET_H | ||
28 | #define WIDGET_H | ||
29 | |||
30 | #include <qapplication.h> | ||
31 | #include <qwidget.h> | ||
32 | #include <qlabel.h> | ||
33 | #include <qtimer.h> | ||
34 | #include <qcolor.h> | ||
35 | #include <qkeycode.h> | ||
36 | #include <qscrollbar.h> | ||
37 | |||
38 | #include <qpopupmenu.h> | ||
39 | |||
40 | #include "common.h" | ||
41 | |||
42 | extern unsigned short vt100_graphics[32]; | ||
43 | |||
44 | class Session; | ||
45 | |||
46 | // class Konsole; | ||
47 | |||
48 | class Widget : public QFrame | ||
49 | // a widget representing attributed text | ||
50 | { Q_OBJECT | ||
51 | |||
52 | // friend class Konsole; | ||
53 | |||
54 | public: | ||
55 | |||
56 | Widget(QWidget *parent=0, const char *name=0); | ||
57 | virtual ~Widget(); | ||
58 | |||
59 | public: | ||
60 | |||
61 | QColor getDefaultBackColor(); | ||
62 | |||
63 | const ColorEntry* getColorTable() const; | ||
64 | const ColorEntry* getdefaultColorTable() const; | ||
65 | void setColorTable(const ColorEntry table[]); | ||
66 | |||
67 | void setScrollbarLocation(int loc); | ||
68 | enum { SCRNONE=0, SCRLEFT=1, SCRRIGHT=2 }; | ||
69 | |||
70 | void setScroll(int cursor, int lines); | ||
71 | void doScroll(int lines); | ||
72 | |||
73 | void emitSelection(); | ||
74 | |||
75 | public: | ||
76 | |||
77 | void setImage(const Character* const newimg, int lines, int columns); | ||
78 | |||
79 | int Lines() { return lines; } | ||
80 | int Columns() { return columns; } | ||
81 | |||
82 | void calcGeometry(); | ||
83 | void propagateSize(); | ||
84 | QSize calcSize(int cols, int lins) const; | ||
85 | |||
86 | QSize sizeHint() const; | ||
87 | |||
88 | public: | ||
89 | |||
90 | void Bell(); | ||
91 | void emitText(QString text); | ||
92 | void pasteClipboard(); | ||
93 | |||
94 | signals: | ||
95 | |||
96 | void keyPressedSignal(QKeyEvent *e); | ||
97 | void mouseSignal(int cb, int cx, int cy); | ||
98 | void changedImageSizeSignal(int lines, int columns); | ||
99 | void changedHistoryCursor(int value); | ||
100 | void configureRequest( Widget*, int state, int x, int y ); | ||
101 | |||
102 | void clearSelectionSignal(); | ||
103 | void beginSelectionSignal( const int x, const int y ); | ||
104 | void extendSelectionSignal( const int x, const int y ); | ||
105 | void endSelectionSignal(const BOOL preserve_line_breaks); | ||
106 | |||
107 | |||
108 | protected: | ||
109 | |||
110 | virtual void styleChange( QStyle& ); | ||
111 | |||
112 | bool eventFilter( QObject *, QEvent * ); | ||
113 | |||
114 | void drawAttrStr(QPainter &paint, QRect rect, | ||
115 | QString& str, Character attr, BOOL pm, BOOL clear); | ||
116 | void paintEvent( QPaintEvent * ); | ||
117 | |||
118 | void resizeEvent(QResizeEvent*); | ||
119 | |||
120 | void fontChange(const QFont &font); | ||
121 | void frameChanged(); | ||
122 | |||
123 | void mouseDoubleClickEvent(QMouseEvent* ev); | ||
124 | void mousePressEvent( QMouseEvent* ); | ||
125 | void mouseReleaseEvent( QMouseEvent* ); | ||
126 | void mouseMoveEvent( QMouseEvent* ); | ||
127 | |||
128 | void focusInEvent( QFocusEvent * ); | ||
129 | void focusOutEvent( QFocusEvent * ); | ||
130 | bool focusNextPrevChild( bool next ); | ||
131 | |||
132 | #ifndef QT_NO_DRAGANDDROP | ||
133 | // Dnd | ||
134 | void dragEnterEvent(QDragEnterEvent* event); | ||
135 | void dropEvent(QDropEvent* event); | ||
136 | #endif | ||
137 | |||
138 | virtual int charClass(char) const; | ||
139 | |||
140 | void clearImage(); | ||
141 | |||
142 | public: | ||
143 | const QPixmap *backgroundPixmap(); | ||
144 | |||
145 | void setSelection(const QString &t); | ||
146 | |||
147 | virtual void setFont(const QFont &); | ||
148 | void setVTFont(const QFont &); | ||
149 | QFont getVTFont(); | ||
150 | |||
151 | void setMouseMarks(bool on); | ||
152 | |||
153 | public slots: | ||
154 | |||
155 | void onClearSelection(); | ||
156 | |||
157 | protected slots: | ||
158 | |||
159 | void scrollChanged(int value); | ||
160 | void blinkEvent(); | ||
161 | |||
162 | private: | ||
163 | |||
164 | QChar (*fontMap)(QChar); // possible vt100 font extention | ||
165 | |||
166 | bool fixed_font; // has fixed pitch | ||
167 | int font_h; // height | ||
168 | int font_w; // width | ||
169 | int font_a; // ascend | ||
170 | |||
171 | int blX; // actual offset (left) | ||
172 | int brX; // actual offset (right) | ||
173 | int bY; // actual offset | ||
174 | |||
175 | int lines; | ||
176 | int columns; | ||
177 | Character *image; // [lines][columns] | ||
178 | |||
179 | ColorEntry color_table[TABLE_COLORS]; | ||
180 | |||
181 | BOOL resizing; | ||
182 | bool mouse_marks; | ||
183 | |||
184 | void makeImage(); | ||
185 | |||
186 | QPoint iPntSel; // initial selection point | ||
187 | QPoint pntSel; // current selection point | ||
188 | int actSel; // selection state | ||
189 | BOOL word_selection_mode; | ||
190 | BOOL preserve_line_breaks; | ||
191 | |||
192 | QClipboard* cb; | ||
193 | QScrollBar* scrollbar; | ||
194 | int scrollLoc; | ||
195 | |||
196 | //#define SCRNONE 0 | ||
197 | //#define SCRLEFT 1 | ||
198 | //#define SCRRIGHT 2 | ||
199 | |||
200 | BOOL blinking; // hide text in paintEvent | ||
201 | BOOL hasBlinker; // has characters to blink | ||
202 | QTimer* blinkT; // active when hasBlinker | ||
203 | QPopupMenu* m_drop; | ||
204 | QString dropText; | ||
205 | public: | ||
206 | // current session in this widget | ||
207 | // ibot: switch from TESession to Session! | ||
208 | Session *currentSession; | ||
209 | private slots: | ||
210 | void drop_menu_activated(int item); | ||
211 | }; | ||
212 | |||
213 | #endif // TE_WIDGET_H | ||
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp deleted file mode 100644 index afded92..0000000 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* widget_layer.cpp Widget Layer */ | ||
4 | /* */ | ||
5 | /* opie developers <opie@handhelds.org> */ | ||
6 | /* */ | ||
7 | /* ------------------------------------------------------------------------- */ | ||
8 | |||
9 | |||
10 | |||
11 | #include "widget_layer.h" | ||
12 | |||
13 | |||
14 | #include <string.h> | ||
15 | //#include < | ||
16 | |||
17 | |||
18 | |||
19 | |||
20 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) | ||
21 | { | ||
22 | // get the clipboard | ||
23 | m_clipboard = QApplication::clipboard(); | ||
24 | |||
25 | // when data on clipboard changes, clear selection | ||
26 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
27 | (QObject*)this, SLOT( onClearSelection() ) ); | ||
28 | |||
29 | // initialize vars: | ||
30 | m_lines = 1; | ||
31 | m_columns = 1; | ||
32 | m_resizing = false; | ||
33 | |||
34 | // just for demonstrating | ||
35 | //m_image = QArray<Character>( m_lines * m_columns ); | ||
36 | m_image = QArray<Character>( 1 ); | ||
37 | |||
38 | // we need to install an event filter, | ||
39 | // to emit keypresses. | ||
40 | qApp->installEventFilter( this ); | ||
41 | |||
42 | } | ||
43 | |||
44 | |||
45 | WidgetLayer::~WidgetLayer() | ||
46 | { | ||
47 | // clean up | ||
48 | delete m_image; | ||
49 | } | ||
50 | |||
51 | |||
52 | QSize WidgetLayer::sizeHint() | ||
53 | { | ||
54 | return size(); | ||
55 | } | ||
56 | |||
57 | |||
58 | /* --------------------------------- audio ---------------------------------- */ | ||
59 | |||
60 | void WidgetLayer::bell() | ||
61 | { | ||
62 | QApplication::beep(); | ||
63 | } | ||
64 | |||
65 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | ||
66 | { | ||
67 | if ( (e->type() == QEvent::Accel || | ||
68 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
69 | static_cast<QKeyEvent *>( e )->ignore(); | ||
70 | return true; | ||
71 | } | ||
72 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
73 | return false; // not us | ||
74 | |||
75 | #ifdef FAKE_CTRL_AND_ALT | ||
76 | static bool control = false; | ||
77 | static bool alt = false; | ||
78 | bool dele = false; | ||
79 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
80 | QKeyEvent* ke = (QKeyEvent*)e; | ||
81 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
82 | switch (ke->key()) { | ||
83 | case Key_F9: // let this be "Control" | ||
84 | control = keydown; | ||
85 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
86 | dele=TRUE; | ||
87 | break; | ||
88 | case Key_F13: // let this be "Alt" | ||
89 | alt = keydown; | ||
90 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
91 | dele=TRUE; | ||
92 | break; | ||
93 | default: | ||
94 | if ( control ) { | ||
95 | int a = toupper(ke->ascii())-64; | ||
96 | if ( a >= 0 && a < ' ' ) { | ||
97 | e = new QKeyEvent(e->type(), ke->key(), | ||
98 | a, ke->state()|ControlButton, | ||
99 | QChar(a,0)); | ||
100 | dele=TRUE; | ||
101 | } | ||
102 | } | ||
103 | if ( alt ) { | ||
104 | e = new QKeyEvent(e->type(), ke->key(), | ||
105 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
106 | dele=TRUE; | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | #endif | ||
111 | |||
112 | if ( e->type() == QEvent::KeyPress ) { | ||
113 | QKeyEvent* ke = (QKeyEvent*)e; | ||
114 | //actSel=0; // Key stroke implies a screen update, so Widget won't | ||
115 | // know where the current selection is. | ||
116 | |||
117 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
118 | insertText("\\"); // expose | ||
119 | } else | ||
120 | emit keyPressed( ke ); // expose | ||
121 | ke->accept(); | ||
122 | #ifdef FAKE_CTRL_AND_ALT | ||
123 | if ( dele ) delete e; | ||
124 | #endif | ||
125 | return true; // stop the event | ||
126 | } | ||
127 | return QFrame::eventFilter( obj, e ); | ||
128 | } | ||
129 | |||
130 | |||
131 | /* --------------------------------- screen --------------------------------- */ | ||
132 | |||
133 | |||
134 | void WidgetLayer::propagateSize() | ||
135 | { | ||
136 | QArray<Character> oldimage = m_image.copy(); | ||
137 | int oldlines = m_lines; | ||
138 | int oldcolumns = m_columns; | ||
139 | |||
140 | makeImage(); | ||
141 | |||
142 | // copy old image, to reduce flicker | ||
143 | if ( ! oldimage.isEmpty() ) | ||
144 | { | ||
145 | int lins = QMIN( oldlines, m_lines ); | ||
146 | int cols = QMIN( oldcolumns, m_columns ); | ||
147 | for ( int lin = 0; lin < lins; ++lin ) | ||
148 | { | ||
149 | memcpy( (void*) &m_image[m_columns*lin], | ||
150 | (void*) &oldimage[oldcolumns*lin], | ||
151 | cols*sizeof( Character ) ); | ||
152 | } | ||
153 | } | ||
154 | else | ||
155 | clearImage(); | ||
156 | |||
157 | delete oldimage; | ||
158 | |||
159 | m_resizing = true; | ||
160 | emit imageSizeChanged( m_lines, m_columns ); | ||
161 | m_resizing = false; | ||
162 | } | ||
163 | |||
164 | void WidgetLayer::makeImage() | ||
165 | { | ||
166 | calcGeometry(); | ||
167 | m_image = QArray<Character>( m_columns * m_lines ); | ||
168 | clearImage(); | ||
169 | } | ||
170 | |||
171 | void WidgetLayer::clearImage() | ||
172 | { | ||
173 | //should this belong here?? | ||
174 | for ( int y = 0; y < m_lines; y++ ) | ||
175 | for ( int x = 0; x < m_columns; x++ ) | ||
176 | { | ||
177 | m_image[loc(x,y)].c = 0xff; | ||
178 | m_image[loc(x,y)].f = 0xff; | ||
179 | m_image[loc(x,y)].b = 0xff; | ||
180 | m_image[loc(x,y)].r = 0xff; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | /* --------------------------------- selection ------------------------------ */ | ||
185 | |||
186 | void WidgetLayer::pasteClipboard() | ||
187 | { | ||
188 | insertSelection(); | ||
189 | } | ||
190 | |||
191 | |||
192 | void WidgetLayer::insertSelection() | ||
193 | { | ||
194 | QString text = QApplication::clipboard()->text(); | ||
195 | if ( ! text.isNull() ) | ||
196 | { | ||
197 | text.replace( QRegExp( "\n" ), "\r" ); | ||
198 | insertText( text ); | ||
199 | // selection should be unselected | ||
200 | emit selectionCleared(); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | void WidgetLayer::insertText( QString text ) | ||
205 | { | ||
206 | // text is inserted as key event | ||
207 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); | ||
208 | emit keyPressed( &e ); | ||
209 | } | ||
210 | |||
211 | void WidgetLayer::onClearSelection() | ||
212 | { | ||
213 | emit selectionCleared(); | ||
214 | } | ||
215 | |||
216 | void WidgetLayer::setSelection( const QString& text ) | ||
217 | { | ||
218 | // why get the clipboard, we have it as instance var... | ||
219 | QObject *m_clipboard = QApplication::clipboard(); | ||
220 | |||
221 | // we know, that cliboard changes, when we change clipboard | ||
222 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
223 | (QObject*) this, SLOT( selectionCleared() ) ); | ||
224 | |||
225 | QApplication::clipboard()->setText( text ); | ||
226 | |||
227 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | ||
228 | (QObject*) this, SLOT( selectionCleared() ) ); | ||
229 | } | ||
230 | |||
231 | |||
232 | ///////// | ||
233 | // special font characters | ||
234 | ///////// | ||
235 | unsigned short vt100_graphics[32] = | ||
236 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | ||
237 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | ||
238 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | ||
239 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | ||
240 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | ||
241 | }; | ||
242 | |||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h deleted file mode 100644 index 6812711..0000000 --- a/noncore/apps/opie-console/widget_layer.h +++ b/dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* [widget_layer.h] Widget Layer */ | ||
4 | /* */ | ||
5 | /* -------------------------------------------------------------------------- */ | ||
6 | |||
7 | // proposal of a widget Layer in opie-console | ||
8 | // | ||
9 | // fellow devels: | ||
10 | // just mail me (ibotty@web.de), what you additionally need from the main widget | ||
11 | // (or say in chat) | ||
12 | |||
13 | #ifndef WIDGET_LAYER_H | ||
14 | #define WIDGET_LAYER_H | ||
15 | |||
16 | // qt includes | ||
17 | #include <qapplication.h> | ||
18 | #include <qframe.h> | ||
19 | #include <qarray.h> | ||
20 | #include <qtimer.h> | ||
21 | #include <qkeycode.h> | ||
22 | #include <qclipboard.h> | ||
23 | |||
24 | |||
25 | // opie-console includes | ||
26 | #include "session.h" | ||
27 | #include "common.h" | ||
28 | #include "profile.h" | ||
29 | |||
30 | |||
31 | /* | ||
32 | * given a pseudo location ( column, line ), | ||
33 | * returns the actual index, in the QArray<Character> | ||
34 | */ | ||
35 | #define loc(X,Y) ((Y)*m_columns+(X)) | ||
36 | |||
37 | |||
38 | |||
39 | extern unsigned short vt100_graphics[32]; | ||
40 | |||
41 | class WidgetLayer : public QFrame | ||
42 | { Q_OBJECT | ||
43 | |||
44 | public: | ||
45 | |||
46 | /** | ||
47 | * constructor | ||
48 | * @param const Profile &config, the configuration for this widget | ||
49 | * @param QWidget *parent, the parent widget | ||
50 | * @param const char *name, the name of the widget, defaults to "" | ||
51 | */ | ||
52 | WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); | ||
53 | |||
54 | /** | ||
55 | * destructor | ||
56 | */ | ||
57 | virtual ~WidgetLayer(); | ||
58 | |||
59 | public: | ||
60 | /** | ||
61 | * sets the image | ||
62 | * @param QArray<Character> const newimg, the new image | ||
63 | * @param int lines, lines count of newimg | ||
64 | * @param int columns, columns count of newimg | ||
65 | */ | ||
66 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; | ||
67 | |||
68 | /** | ||
69 | * annoy the user | ||
70 | */ | ||
71 | void bell(); | ||
72 | |||
73 | /** | ||
74 | * @return int m_lines, the lines count | ||
75 | */ | ||
76 | int lines(){ return m_lines; } | ||
77 | |||
78 | /** | ||
79 | * @return int m_columns, the columns count | ||
80 | */ | ||
81 | int columns(){ return m_columns; } | ||
82 | |||
83 | /** | ||
84 | * insert current selection (currently this is only the clipboard) | ||
85 | */ | ||
86 | void insertSelection(); | ||
87 | |||
88 | /** | ||
89 | * insert text | ||
90 | * @param QString text, the text to be inserted | ||
91 | */ | ||
92 | void insertText( QString text ); | ||
93 | |||
94 | /** | ||
95 | * set selection (clipboard) to text | ||
96 | * @param const QString &text, the text to be selected | ||
97 | */ | ||
98 | void setSelection( const QString &text ); | ||
99 | |||
100 | /** | ||
101 | * paste content of clipboard | ||
102 | */ | ||
103 | void pasteClipboard(); | ||
104 | |||
105 | |||
106 | /** | ||
107 | * reload configuration | ||
108 | * @param const Profile& config, the config to be used (may be the same as in constructor) | ||
109 | */ | ||
110 | virtual void reloadConfig( const Profile& config ) = 0; | ||
111 | |||
112 | |||
113 | /** | ||
114 | * sets the scrollbar (if implemented by successor of this class) | ||
115 | */ | ||
116 | virtual void setScroll( int cursor, int slines ) = 0; | ||
117 | |||
118 | /** | ||
119 | * scrolls (if implemented, by successor of this class) | ||
120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) | ||
121 | */ | ||
122 | virtual void scroll( int value ) = 0; | ||
123 | |||
124 | |||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | ||
126 | |||
127 | |||
128 | QSize sizeHint(); | ||
129 | |||
130 | virtual QSize calcSize( int cols, int lins ) const = 0; | ||
131 | signals: | ||
132 | |||
133 | /** | ||
134 | * key was pressed | ||
135 | */ | ||
136 | void keyPressed( QKeyEvent *e ); | ||
137 | |||
138 | /** | ||
139 | * whenever Mouse selects something | ||
140 | * @param int button, the button that us pressed : | ||
141 | * 0left Button | ||
142 | * 3Button released | ||
143 | * @param int x, x position | ||
144 | * @param int y, y position | ||
145 | * | ||
146 | * // numbering due to layout in old TEWidget | ||
147 | */ | ||
148 | void mousePressed( int button, int x, int y ); | ||
149 | |||
150 | /** | ||
151 | * size of image changed | ||
152 | * @param int lines, line count of new size | ||
153 | * @param int columns, column count of new size | ||
154 | */ | ||
155 | void imageSizeChanged( int lines, int columns ); | ||
156 | |||
157 | /** | ||
158 | * cursor in history changed | ||
159 | * @param int value, value of history cursor | ||
160 | */ | ||
161 | void historyCursorChanged( int value ); | ||
162 | |||
163 | /** | ||
164 | * selection should be cleared | ||
165 | */ | ||
166 | void selectionCleared(); | ||
167 | |||
168 | /** | ||
169 | * selection begin | ||
170 | * @param const int x, x position | ||
171 | * @param const int y, y position | ||
172 | */ | ||
173 | void selectionBegin( const int x, const int y ); | ||
174 | |||
175 | /** | ||
176 | * selection extended | ||
177 | * (from begin (s.a.) to x, y) | ||
178 | * @param const int x, x position | ||
179 | * @param const int y, y position | ||
180 | */ | ||
181 | void selectionExtended( const int x, const int y ); | ||
182 | |||
183 | /** | ||
184 | * selection end | ||
185 | * @param const bool lineBreakPreserve, preserve line breaks in selection | ||
186 | */ | ||
187 | void selectionEnd( const bool lineBreakPreserve ); | ||
188 | |||
189 | |||
190 | |||
191 | // protected methods | ||
192 | protected: | ||
193 | |||
194 | // image operations | ||
195 | |||
196 | /** | ||
197 | * changes image, to suit new size | ||
198 | * TODO: find meaningful name! | ||
199 | */ | ||
200 | void propagateSize(); | ||
201 | |||
202 | /** | ||
203 | *determines count of lines and columns | ||
204 | */ | ||
205 | virtual void calcGeometry() = 0; | ||
206 | |||
207 | /** | ||
208 | * makes an empty image | ||
209 | */ | ||
210 | void makeImage(); | ||
211 | |||
212 | /** | ||
213 | * clears the image | ||
214 | */ | ||
215 | void clearImage(); | ||
216 | |||
217 | protected slots: | ||
218 | |||
219 | /** | ||
220 | * clear selection | ||
221 | */ | ||
222 | void onClearSelection(); | ||
223 | |||
224 | |||
225 | // protected vars | ||
226 | protected: | ||
227 | |||
228 | /** | ||
229 | * current Session | ||
230 | */ | ||
231 | Session *m_session; | ||
232 | |||
233 | /** | ||
234 | * current character image | ||
235 | * | ||
236 | * a Character at loc( column, line ) | ||
237 | * has the actual index: | ||
238 | * ix = line * m_columns + column; | ||
239 | * | ||
240 | * use loc( x, y ) macro to access. | ||
241 | */ | ||
242 | QArray<Character> m_image; | ||
243 | |||
244 | /** | ||
245 | * lines count | ||
246 | */ | ||
247 | int m_lines; | ||
248 | |||
249 | /** | ||
250 | * columns count | ||
251 | */ | ||
252 | int m_columns; | ||
253 | |||
254 | /** | ||
255 | * clipboard | ||
256 | */ | ||
257 | QClipboard* m_clipboard; | ||
258 | |||
259 | /** | ||
260 | * whether widget is resizing | ||
261 | */ | ||
262 | bool m_resizing; | ||
263 | }; | ||
264 | |||
265 | #endif // WIDGET_LAYER_H | ||