author | zecke <zecke> | 2004-03-14 17:56:46 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 17:56:46 (UTC) |
commit | 98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54 (patch) (unidiff) | |
tree | 8a440150cc5f66ac5dfce1062b436d9878517779 | |
parent | d69b11f67e3118f86d068c38c422984d754e13cc (diff) | |
download | opie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.zip opie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.tar.gz opie-98bbe5561e8e1a862e19a3d0a0d49ed90ef15b54.tar.bz2 |
ODP and only ODP
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 1 | ||||
-rw-r--r-- | core/apps/helpbrowser/main.cpp | 1 | ||||
-rw-r--r-- | core/apps/qcop/config.in | 4 | ||||
-rw-r--r-- | core/apps/textedit/main.cpp | 1 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 4 | ||||
-rw-r--r-- | core/apps/textedit/textedit.h | 2 |
7 files changed, 8 insertions, 6 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 281835e..c5df47f 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,819 +1,820 @@ | |||
1 | 1 | ||
2 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
3 | /* */ | 3 | /* */ |
4 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
5 | /* */ | 5 | /* */ |
6 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
7 | /* */ | 7 | /* */ |
8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
9 | /* */ | 9 | /* */ |
10 | /* This file is part of Konsole, an X terminal. */ | 10 | /* This file is part of Konsole, an X terminal. */ |
11 | /* */ | 11 | /* */ |
12 | /* The material contained in here more or less directly orginates from */ | 12 | /* The material contained in here more or less directly orginates from */ |
13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
14 | /* */ | 14 | /* */ |
15 | /* ---------------------------------------------------------------------- */ | 15 | /* ---------------------------------------------------------------------- */ |
16 | /* */ | 16 | /* */ |
17 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
18 | /* */ | 18 | /* */ |
19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
20 | /* */ | 20 | /* */ |
21 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
23 | // enhancements added by Phillip Kuhn | 23 | // enhancements added by Phillip Kuhn |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
31 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | 35 | ||
36 | #include <qmenubar.h> | 36 | #include <qmenubar.h> |
37 | #include <qtabbar.h> | 37 | #include <qtabbar.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qfontdatabase.h> | 39 | #include <qfontdatabase.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | 43 | ||
44 | #include <sys/wait.h> | 44 | #include <sys/wait.h> |
45 | #include <stdio.h> | 45 | #include <stdio.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <assert.h> | 47 | #include <assert.h> |
48 | 48 | ||
49 | #include "konsole.h" | 49 | #include "konsole.h" |
50 | #include "commandeditdialog.h" | 50 | #include "commandeditdialog.h" |
51 | 51 | ||
52 | using namespace Opie; | ||
52 | class EKNumTabBar : public QTabBar | 53 | class EKNumTabBar : public QTabBar |
53 | { | 54 | { |
54 | public: | 55 | public: |
55 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 56 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
56 | QTabBar(parent, name) | 57 | QTabBar(parent, name) |
57 | {} | 58 | {} |
58 | 59 | ||
59 | // QList<QTab> *getTabList() { return(tabList()); } | 60 | // QList<QTab> *getTabList() { return(tabList()); } |
60 | 61 | ||
61 | void numberTabs() | 62 | void numberTabs() |
62 | { | 63 | { |
63 | // Yes, it really is this messy. QTabWidget needs functions | 64 | // Yes, it really is this messy. QTabWidget needs functions |
64 | // that provide acces to tabs in a sequential way. | 65 | // that provide acces to tabs in a sequential way. |
65 | int m=INT_MIN; | 66 | int m=INT_MIN; |
66 | for (int i=0; i<count(); i++) | 67 | for (int i=0; i<count(); i++) |
67 | { | 68 | { |
68 | QTab* left=0; | 69 | QTab* left=0; |
69 | QListIterator<QTab> it(*tabList()); | 70 | QListIterator<QTab> it(*tabList()); |
70 | int x=INT_MAX; | 71 | int x=INT_MAX; |
71 | for( QTab* t; (t=it.current()); ++it ) | 72 | for( QTab* t; (t=it.current()); ++it ) |
72 | { | 73 | { |
73 | int tx = t->rect().x(); | 74 | int tx = t->rect().x(); |
74 | if ( tx<x && tx>m ) | 75 | if ( tx<x && tx>m ) |
75 | { | 76 | { |
76 | x = tx; | 77 | x = tx; |
77 | left = t; | 78 | left = t; |
78 | } | 79 | } |
79 | } | 80 | } |
80 | if ( left ) | 81 | if ( left ) |
81 | { | 82 | { |
82 | left->setText(QString::number(i+1)); | 83 | left->setText(QString::number(i+1)); |
83 | m = left->rect().x(); | 84 | m = left->rect().x(); |
84 | } | 85 | } |
85 | } | 86 | } |
86 | } | 87 | } |
87 | 88 | ||
88 | virtual QSize sizeHint() const | 89 | virtual QSize sizeHint() const |
89 | { | 90 | { |
90 | if (isHidden()) | 91 | if (isHidden()) |
91 | { | 92 | { |
92 | return(QSize(0,0)); | 93 | return(QSize(0,0)); |
93 | } | 94 | } |
94 | else | 95 | else |
95 | { | 96 | { |
96 | QSize size = QTabBar::sizeHint(); | 97 | QSize size = QTabBar::sizeHint(); |
97 | int shrink = 5; | 98 | int shrink = 5; |
98 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 99 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
99 | { | 100 | { |
100 | shrink = 10; | 101 | shrink = 10; |
101 | } | 102 | } |
102 | size.setHeight(size.height() - shrink); | 103 | size.setHeight(size.height() - shrink); |
103 | return(size); | 104 | return(size); |
104 | } | 105 | } |
105 | } | 106 | } |
106 | 107 | ||
107 | }; | 108 | }; |
108 | 109 | ||
109 | class EKNumTabWidget : public QTabWidget | 110 | class EKNumTabWidget : public QTabWidget |
110 | { | 111 | { |
111 | public: | 112 | public: |
112 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 113 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
113 | { | 114 | { |
114 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 115 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
115 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 116 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
116 | } | 117 | } |
117 | 118 | ||
118 | EKNumTabBar *getTabBar() const | 119 | EKNumTabBar *getTabBar() const |
119 | { | 120 | { |
120 | return ((EKNumTabBar*)tabBar()); | 121 | return ((EKNumTabBar*)tabBar()); |
121 | } | 122 | } |
122 | 123 | ||
123 | 124 | ||
124 | void addTab(QWidget* w) | 125 | void addTab(QWidget* w) |
125 | { | 126 | { |
126 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 127 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
127 | QTabWidget::addTab(w,t); | 128 | QTabWidget::addTab(w,t); |
128 | } | 129 | } |
129 | 130 | ||
130 | void removeTab(QWidget* w) | 131 | void removeTab(QWidget* w) |
131 | { | 132 | { |
132 | removePage(w); | 133 | removePage(w); |
133 | ((EKNumTabBar*)tabBar())->numberTabs(); | 134 | ((EKNumTabBar*)tabBar())->numberTabs(); |
134 | } | 135 | } |
135 | }; | 136 | }; |
136 | 137 | ||
137 | // This could be configurable or dynamicly generated from the bash history | 138 | // This could be configurable or dynamicly generated from the bash history |
138 | // file of the user | 139 | // file of the user |
139 | static const char *commonCmds[] = | 140 | static const char *commonCmds[] = |
140 | { | 141 | { |
141 | "ls ", // I left this here, cause it looks better than the first alpha | 142 | "ls ", // I left this here, cause it looks better than the first alpha |
142 | "cardctl eject", | 143 | "cardctl eject", |
143 | "cat ", | 144 | "cat ", |
144 | "cd ", | 145 | "cd ", |
145 | "chmod ", | 146 | "chmod ", |
146 | "clear", | 147 | "clear", |
147 | "cp ", | 148 | "cp ", |
148 | "dc ", | 149 | "dc ", |
149 | "df ", | 150 | "df ", |
150 | "dmesg", | 151 | "dmesg", |
151 | "echo ", | 152 | "echo ", |
152 | "env", | 153 | "env", |
153 | "find ", | 154 | "find ", |
154 | "free", | 155 | "free", |
155 | "grep ", | 156 | "grep ", |
156 | "ifconfig ", | 157 | "ifconfig ", |
157 | "ipkg ", | 158 | "ipkg ", |
158 | "mkdir ", | 159 | "mkdir ", |
159 | "mv ", | 160 | "mv ", |
160 | "nc localhost 7776", | 161 | "nc localhost 7776", |
161 | "nc localhost 7777", | 162 | "nc localhost 7777", |
162 | "netstat ", | 163 | "netstat ", |
163 | "nslookup ", | 164 | "nslookup ", |
164 | "ping ", | 165 | "ping ", |
165 | "ps aux", | 166 | "ps aux", |
166 | "pwd ", | 167 | "pwd ", |
167 | "qcop QPE/System 'linkChanged(QString)' ''", | 168 | "qcop QPE/System 'linkChanged(QString)' ''", |
168 | "qcop QPE/System 'restart()'", | 169 | "qcop QPE/System 'restart()'", |
169 | "qcop QPE/System 'quit()'", | 170 | "qcop QPE/System 'quit()'", |
170 | "rm ", | 171 | "rm ", |
171 | "rmdir ", | 172 | "rmdir ", |
172 | "route ", | 173 | "route ", |
173 | "set ", | 174 | "set ", |
174 | "traceroute", | 175 | "traceroute", |
175 | 176 | ||
176 | /* | 177 | /* |
177 | "gzip", | 178 | "gzip", |
178 | "gunzip", | 179 | "gunzip", |
179 | "chgrp", | 180 | "chgrp", |
180 | "chown", | 181 | "chown", |
181 | "date", | 182 | "date", |
182 | "dd", | 183 | "dd", |
183 | "df", | 184 | "df", |
184 | "dmesg", | 185 | "dmesg", |
185 | "fuser", | 186 | "fuser", |
186 | "hostname", | 187 | "hostname", |
187 | "kill", | 188 | "kill", |
188 | "killall", | 189 | "killall", |
189 | "ln", | 190 | "ln", |
190 | "ping", | 191 | "ping", |
191 | "mount", | 192 | "mount", |
192 | "more", | 193 | "more", |
193 | "sort", | 194 | "sort", |
194 | "touch", | 195 | "touch", |
195 | "umount", | 196 | "umount", |
196 | "mknod", | 197 | "mknod", |
197 | "netstat", | 198 | "netstat", |
198 | */ | 199 | */ |
199 | 200 | ||
200 | "exit", | 201 | "exit", |
201 | NULL | 202 | NULL |
202 | }; | 203 | }; |
203 | 204 | ||
204 | 205 | ||
205 | static void konsoleInit(const char** shell) { | 206 | static void konsoleInit(const char** shell) { |
206 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 207 | if(setuid(getuid()) !=0) qDebug("setuid failed"); |
207 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 208 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges |
208 | 209 | ||
209 | 210 | ||
210 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 211 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
211 | 212 | ||
212 | qDebug("keyboard grabbed"); | 213 | qDebug("keyboard grabbed"); |
213 | #ifdef FAKE_CTRL_AND_ALT | 214 | #ifdef FAKE_CTRL_AND_ALT |
214 | qDebug("Fake Ctrl and Alt defined"); | 215 | qDebug("Fake Ctrl and Alt defined"); |
215 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 216 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
216 | #endif | 217 | #endif |
217 | 218 | ||
218 | *shell = getenv("SHELL"); | 219 | *shell = getenv("SHELL"); |
219 | qWarning("SHell initially is %s", *shell ); | 220 | qWarning("SHell initially is %s", *shell ); |
220 | 221 | ||
221 | if (shell == NULL || *shell == '\0') { | 222 | if (shell == NULL || *shell == '\0') { |
222 | struct passwd *ent = 0; | 223 | struct passwd *ent = 0; |
223 | uid_t me = getuid(); | 224 | uid_t me = getuid(); |
224 | *shell = "/bin/sh"; | 225 | *shell = "/bin/sh"; |
225 | 226 | ||
226 | while ( (ent = getpwent()) != 0 ) { | 227 | while ( (ent = getpwent()) != 0 ) { |
227 | if (ent->pw_uid == me) { | 228 | if (ent->pw_uid == me) { |
228 | if (ent->pw_shell != "") | 229 | if (ent->pw_shell != "") |
229 | *shell = ent->pw_shell; | 230 | *shell = ent->pw_shell; |
230 | break; | 231 | break; |
231 | } | 232 | } |
232 | } | 233 | } |
233 | endpwent(); | 234 | endpwent(); |
234 | } | 235 | } |
235 | 236 | ||
236 | if( putenv((char*)"COLORTERM=") !=0) | 237 | if( putenv((char*)"COLORTERM=") !=0) |
237 | qDebug("putenv failed"); // to trigger mc's color detection | 238 | qDebug("putenv failed"); // to trigger mc's color detection |
238 | } | 239 | } |
239 | 240 | ||
240 | 241 | ||
241 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 242 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
242 | QMainWindow(parent, name, fl) | 243 | QMainWindow(parent, name, fl) |
243 | { | 244 | { |
244 | QStrList tmp; const char* shell; | 245 | QStrList tmp; const char* shell; |
245 | 246 | ||
246 | konsoleInit( &shell); | 247 | konsoleInit( &shell); |
247 | init(shell,tmp); | 248 | init(shell,tmp); |
248 | } | 249 | } |
249 | 250 | ||
250 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 251 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
251 | : QMainWindow(0, name) | 252 | : QMainWindow(0, name) |
252 | { | 253 | { |
253 | init(_pgm,_args); | 254 | init(_pgm,_args); |
254 | } | 255 | } |
255 | 256 | ||
256 | struct HistoryItem | 257 | struct HistoryItem |
257 | { | 258 | { |
258 | HistoryItem(int c, const QString &l) | 259 | HistoryItem(int c, const QString &l) |
259 | { | 260 | { |
260 | count = c; | 261 | count = c; |
261 | line = l; | 262 | line = l; |
262 | } | 263 | } |
263 | int count; | 264 | int count; |
264 | QString line; | 265 | QString line; |
265 | }; | 266 | }; |
266 | 267 | ||
267 | class HistoryList : public QList<HistoryItem> | 268 | class HistoryList : public QList<HistoryItem> |
268 | { | 269 | { |
269 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 270 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
270 | { | 271 | { |
271 | int c1 = ((HistoryItem*)item1)->count; | 272 | int c1 = ((HistoryItem*)item1)->count; |
272 | int c2 = ((HistoryItem*)item2)->count; | 273 | int c2 = ((HistoryItem*)item2)->count; |
273 | if (c1 > c2) | 274 | if (c1 > c2) |
274 | return(1); | 275 | return(1); |
275 | if (c1 < c2) | 276 | if (c1 < c2) |
276 | return(-1); | 277 | return(-1); |
277 | return(0); | 278 | return(0); |
278 | } | 279 | } |
279 | }; | 280 | }; |
280 | 281 | ||
281 | void Konsole::initCommandList() | 282 | void Konsole::initCommandList() |
282 | { | 283 | { |
283 | // qDebug("Konsole::initCommandList"); | 284 | // qDebug("Konsole::initCommandList"); |
284 | Config cfg( "Konsole" ); | 285 | Config cfg( "Konsole" ); |
285 | cfg.setGroup("Commands"); | 286 | cfg.setGroup("Commands"); |
286 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 287 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
287 | commonCombo->clear(); | 288 | commonCombo->clear(); |
288 | 289 | ||
289 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") | 290 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
290 | { | 291 | { |
291 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
292 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
293 | QFile histfile(histfilename); | 294 | QFile histfile(histfilename); |
294 | // note: compiler barfed on: | 295 | // note: compiler barfed on: |
295 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
296 | if (histfile.open( IO_ReadOnly )) | 297 | if (histfile.open( IO_ReadOnly )) |
297 | { | 298 | { |
298 | QString line; | 299 | QString line; |
299 | uint i; | 300 | uint i; |
300 | HistoryList items; | 301 | HistoryList items; |
301 | 302 | ||
302 | int lineno = 0; | 303 | int lineno = 0; |
303 | while(!histfile.atEnd()) | 304 | while(!histfile.atEnd()) |
304 | { | 305 | { |
305 | if (histfile.readLine(line, 200) < 0) | 306 | if (histfile.readLine(line, 200) < 0) |
306 | { | 307 | { |
307 | break; | 308 | break; |
308 | } | 309 | } |
309 | line = line.left(line.length()-1); | 310 | line = line.left(line.length()-1); |
310 | lineno++; | 311 | lineno++; |
311 | 312 | ||
312 | for(i=0; i<items.count(); i++) | 313 | for(i=0; i<items.count(); i++) |
313 | { | 314 | { |
314 | if (line == items.at(i)->line) | 315 | if (line == items.at(i)->line) |
315 | { | 316 | { |
316 | // weight recent commands & repeated commands more | 317 | // weight recent commands & repeated commands more |
317 | // by adding up the index of each command | 318 | // by adding up the index of each command |
318 | items.at(i)->count += lineno; | 319 | items.at(i)->count += lineno; |
319 | break; | 320 | break; |
320 | } | 321 | } |
321 | } | 322 | } |
322 | if (i >= items.count()) | 323 | if (i >= items.count()) |
323 | { | 324 | { |
324 | items.append(new HistoryItem(lineno, line)); | 325 | items.append(new HistoryItem(lineno, line)); |
325 | } | 326 | } |
326 | } | 327 | } |
327 | items.sort(); | 328 | items.sort(); |
328 | int n = items.count(); | 329 | int n = items.count(); |
329 | if (n > 40) | 330 | if (n > 40) |
330 | { | 331 | { |
331 | n = 40; | 332 | n = 40; |
332 | } | 333 | } |
333 | for(int i=0; i<n; i++) | 334 | for(int i=0; i<n; i++) |
334 | { | 335 | { |
335 | // should insert start of command, but keep whole thing | 336 | // should insert start of command, but keep whole thing |
336 | if (items.at(items.count()-i-1)->line.length() < 30) | 337 | if (items.at(items.count()-i-1)->line.length() < 30) |
337 | { | 338 | { |
338 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 339 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
339 | } | 340 | } |
340 | } | 341 | } |
341 | histfile.close(); | 342 | histfile.close(); |
342 | } | 343 | } |
343 | } | 344 | } |
344 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | 345 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") |
345 | { | 346 | { |
346 | for (int i = 0; commonCmds[i] != NULL; i++) | 347 | for (int i = 0; commonCmds[i] != NULL; i++) |
347 | { | 348 | { |
348 | commonCombo->insertItem(commonCmds[i]); | 349 | commonCombo->insertItem(commonCmds[i]); |
349 | } | 350 | } |
350 | } | 351 | } |
351 | else | 352 | else |
352 | { | 353 | { |
353 | for (int i = 0; i < 100; i++) | 354 | for (int i = 0; i < 100; i++) |
354 | { | 355 | { |
355 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 356 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
356 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 357 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
357 | } | 358 | } |
358 | } | 359 | } |
359 | 360 | ||
360 | 361 | ||
361 | } | 362 | } |
362 | 363 | ||
363 | static void sig_handler(int x) | 364 | static void sig_handler(int x) |
364 | { | 365 | { |
365 | printf("got signal %d\n",x); | 366 | printf("got signal %d\n",x); |
366 | } | 367 | } |
367 | 368 | ||
368 | void Konsole::init(const char* _pgm, QStrList & _args) | 369 | void Konsole::init(const char* _pgm, QStrList & _args) |
369 | { | 370 | { |
370 | 371 | ||
371 | #if 0 | 372 | #if 0 |
372 | for(int i=1; i<=31; i++) | 373 | for(int i=1; i<=31; i++) |
373 | { | 374 | { |
374 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 375 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
375 | && i != SIGINT && i != SIGILL && i != SIGTERM | 376 | && i != SIGINT && i != SIGILL && i != SIGTERM |
376 | && i != SIGBUS) | 377 | && i != SIGBUS) |
377 | signal(i,sig_handler); | 378 | signal(i,sig_handler); |
378 | } | 379 | } |
379 | #endif | 380 | #endif |
380 | signal(SIGSTOP, sig_handler); | 381 | signal(SIGSTOP, sig_handler); |
381 | signal(SIGCONT, sig_handler); | 382 | signal(SIGCONT, sig_handler); |
382 | signal(SIGTSTP, sig_handler); | 383 | signal(SIGTSTP, sig_handler); |
383 | 384 | ||
384 | b_scroll = TRUE; // histon; | 385 | b_scroll = TRUE; // histon; |
385 | n_keytab = 0; | 386 | n_keytab = 0; |
386 | n_render = 0; | 387 | n_render = 0; |
387 | startUp=0; | 388 | startUp=0; |
388 | fromMenu = FALSE; | 389 | fromMenu = FALSE; |
389 | fullscreen = false; | 390 | fullscreen = false; |
390 | 391 | ||
391 | setCaption( tr( "Konsole" ) ); | 392 | setCaption( tr( "Konsole" ) ); |
392 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 393 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); |
393 | 394 | ||
394 | Config cfg( "Konsole" ); | 395 | Config cfg( "Konsole" ); |
395 | cfg.setGroup("Font"); | 396 | cfg.setGroup("Font"); |
396 | QString tmp; | 397 | QString tmp; |
397 | 398 | ||
398 | // initialize the list of allowed fonts /////////////////////////////////// | 399 | // initialize the list of allowed fonts /////////////////////////////////// |
399 | 400 | ||
400 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 401 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
401 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 402 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
402 | 403 | ||
403 | cfont = -1; | 404 | cfont = -1; |
404 | 405 | ||
405 | // this code causes repeated access to all the font files | 406 | // this code causes repeated access to all the font files |
406 | // which does slow down startup | 407 | // which does slow down startup |
407 | QFontDatabase fontDB; | 408 | QFontDatabase fontDB; |
408 | QStringList familyNames; | 409 | QStringList familyNames; |
409 | familyNames = fontDB.families( FALSE ); | 410 | familyNames = fontDB.families( FALSE ); |
410 | QString s; | 411 | QString s; |
411 | int fontIndex = 0; | 412 | int fontIndex = 0; |
412 | int familyNum = 0; | 413 | int familyNum = 0; |
413 | fontList = new QPopupMenu( this ); | 414 | fontList = new QPopupMenu( this ); |
414 | 415 | ||
415 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 416 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
416 | { | 417 | { |
417 | s = familyNames[j]; | 418 | s = familyNames[j]; |
418 | if ( s.contains('-') ) | 419 | if ( s.contains('-') ) |
419 | { | 420 | { |
420 | int i = s.find('-'); | 421 | int i = s.find('-'); |
421 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 422 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
422 | } | 423 | } |
423 | s[0] = s[0].upper(); | 424 | s[0] = s[0].upper(); |
424 | 425 | ||
425 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 426 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
426 | 427 | ||
427 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 428 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
428 | sizes.count()); | 429 | sizes.count()); |
429 | 430 | ||
430 | if (sizes.count() > 0) | 431 | if (sizes.count() > 0) |
431 | { | 432 | { |
432 | QPopupMenu *sizeMenu; | 433 | QPopupMenu *sizeMenu; |
433 | QFont f; | 434 | QFont f; |
434 | int last_width = -1; | 435 | int last_width = -1; |
435 | sizeMenu = NULL; | 436 | sizeMenu = NULL; |
436 | 437 | ||
437 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 438 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
438 | { | 439 | { |
439 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 440 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
440 | // need to divide by 10 on the Z, but not otherwise | 441 | // need to divide by 10 on the Z, but not otherwise |
441 | int size; | 442 | int size; |
442 | 443 | ||
443 | if (i >= (uint)sizes.count()) | 444 | if (i >= (uint)sizes.count()) |
444 | { | 445 | { |
445 | // try for expandable fonts | 446 | // try for expandable fonts |
446 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 447 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
447 | } | 448 | } |
448 | else | 449 | else |
449 | { | 450 | { |
450 | printf("sizes[%d] = %d\n", i, sizes[i]); | 451 | printf("sizes[%d] = %d\n", i, sizes[i]); |
451 | size = sizes[i]; | 452 | size = sizes[i]; |
452 | } | 453 | } |
453 | 454 | ||
454 | f = QFont(familyNames[j], size); | 455 | f = QFont(familyNames[j], size); |
455 | f.setFixedPitch(true); | 456 | f.setFixedPitch(true); |
456 | QFontMetrics fm(f); | 457 | QFontMetrics fm(f); |
457 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 458 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
458 | if (fm.width("l") == fm.width("m") | 459 | if (fm.width("l") == fm.width("m") |
459 | && (i < (uint)sizes.count() | 460 | && (i < (uint)sizes.count() |
460 | || fm.width("m") > last_width)) | 461 | || fm.width("m") > last_width)) |
461 | { | 462 | { |
462 | if (i < (uint)sizes.count()) | 463 | if (i < (uint)sizes.count()) |
463 | { | 464 | { |
464 | last_width = fm.width("m"); | 465 | last_width = fm.width("m"); |
465 | } | 466 | } |
466 | if (sizeMenu == NULL) | 467 | if (sizeMenu == NULL) |
467 | { | 468 | { |
468 | sizeMenu = new QPopupMenu(); | 469 | sizeMenu = new QPopupMenu(); |
469 | } | 470 | } |
470 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 471 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
471 | sizeMenu->setItemParameter(id, fontIndex); | 472 | sizeMenu->setItemParameter(id, fontIndex); |
472 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 473 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
473 | QString name = s + " " + QString::number(size); | 474 | QString name = s + " " + QString::number(size); |
474 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 475 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
475 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 476 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
476 | { | 477 | { |
477 | cfont = fontIndex; | 478 | cfont = fontIndex; |
478 | } | 479 | } |
479 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 480 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
480 | fontIndex++; | 481 | fontIndex++; |
481 | } | 482 | } |
482 | } | 483 | } |
483 | if (sizeMenu) | 484 | if (sizeMenu) |
484 | { | 485 | { |
485 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 486 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
486 | 487 | ||
487 | familyNum++; | 488 | familyNum++; |
488 | } | 489 | } |
489 | } | 490 | } |
490 | 491 | ||
491 | } | 492 | } |
492 | 493 | ||
493 | if (cfont < 0 || cfont >= (int)fonts.count()) | 494 | if (cfont < 0 || cfont >= (int)fonts.count()) |
494 | { | 495 | { |
495 | cfont = 0; | 496 | cfont = 0; |
496 | } | 497 | } |
497 | 498 | ||
498 | // create terminal emulation framework //////////////////////////////////// | 499 | // create terminal emulation framework //////////////////////////////////// |
499 | nsessions = 0; | 500 | nsessions = 0; |
500 | 501 | ||
501 | tab = new EKNumTabWidget(this); | 502 | tab = new EKNumTabWidget(this); |
502 | // tab->setMargin(tab->margin()-5); | 503 | // tab->setMargin(tab->margin()-5); |
503 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 504 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
504 | 505 | ||
505 | // create terminal toolbar //////////////////////////////////////////////// | 506 | // create terminal toolbar //////////////////////////////////////////////// |
506 | setToolBarsMovable( FALSE ); | 507 | setToolBarsMovable( FALSE ); |
507 | menuToolBar = new QToolBar( this ); | 508 | menuToolBar = new QToolBar( this ); |
508 | menuToolBar->setHorizontalStretchable( TRUE ); | 509 | menuToolBar->setHorizontalStretchable( TRUE ); |
509 | 510 | ||
510 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 511 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
511 | 512 | ||
512 | bool c7xx = false; | 513 | bool c7xx = false; |
513 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 514 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
514 | { | 515 | { |
515 | c7xx = true; | 516 | c7xx = true; |
516 | } | 517 | } |
517 | QFont menuFont; | 518 | QFont menuFont; |
518 | menuFont.setPointSize(c7xx? 18 : 10); | 519 | menuFont.setPointSize(c7xx? 18 : 10); |
519 | qApp->setFont(menuFont, true); | 520 | qApp->setFont(menuFont, true); |
520 | 521 | ||
521 | setFont(cfont); | 522 | setFont(cfont); |
522 | 523 | ||
523 | configMenu = new QPopupMenu( this); | 524 | configMenu = new QPopupMenu( this); |
524 | colorMenu = new QPopupMenu( this); | 525 | colorMenu = new QPopupMenu( this); |
525 | scrollMenu = new QPopupMenu( this); | 526 | scrollMenu = new QPopupMenu( this); |
526 | editCommandListMenu = new QPopupMenu( this); | 527 | editCommandListMenu = new QPopupMenu( this); |
527 | 528 | ||
528 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 529 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
529 | 530 | ||
530 | bool listHidden; | 531 | bool listHidden; |
531 | cfg.setGroup("Menubar"); | 532 | cfg.setGroup("Menubar"); |
532 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 533 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
533 | { | 534 | { |
534 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 535 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
535 | listHidden=TRUE; | 536 | listHidden=TRUE; |
536 | } | 537 | } |
537 | else | 538 | else |
538 | { | 539 | { |
539 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 540 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
540 | listHidden=FALSE; | 541 | listHidden=FALSE; |
541 | } | 542 | } |
542 | 543 | ||
543 | cfg.setGroup("Tabs"); | 544 | cfg.setGroup("Tabs"); |
544 | 545 | ||
545 | tabMenu = new QPopupMenu(this); | 546 | tabMenu = new QPopupMenu(this); |
546 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 547 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
547 | tm_top = tabMenu->insertItem(tr("Top")); | 548 | tm_top = tabMenu->insertItem(tr("Top")); |
548 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 549 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
549 | 550 | ||
550 | configMenu->insertItem(tr("Tabs"), tabMenu); | 551 | configMenu->insertItem(tr("Tabs"), tabMenu); |
551 | 552 | ||
552 | tmp=cfg.readEntry("Position","Top"); | 553 | tmp=cfg.readEntry("Position","Top"); |
553 | if(tmp=="Top") | 554 | if(tmp=="Top") |
554 | { | 555 | { |
555 | tab->setTabPosition(QTabWidget::Top); | 556 | tab->setTabPosition(QTabWidget::Top); |
556 | tab->getTabBar()->show(); | 557 | tab->getTabBar()->show(); |
557 | tabPos = tm_top; | 558 | tabPos = tm_top; |
558 | } | 559 | } |
559 | else if (tmp=="Bottom") | 560 | else if (tmp=="Bottom") |
560 | { | 561 | { |
561 | tab->setTabPosition(QTabWidget::Bottom); | 562 | tab->setTabPosition(QTabWidget::Bottom); |
562 | tab->getTabBar()->show(); | 563 | tab->getTabBar()->show(); |
563 | tabPos = tm_bottom; | 564 | tabPos = tm_bottom; |
564 | } | 565 | } |
565 | else | 566 | else |
566 | { | 567 | { |
567 | tab->getTabBar()->hide(); | 568 | tab->getTabBar()->hide(); |
568 | tab->setMargin(tab->margin()); | 569 | tab->setMargin(tab->margin()); |
569 | tabPos = tm_hidden; | 570 | tabPos = tm_hidden; |
570 | } | 571 | } |
571 | 572 | ||
572 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 573 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
573 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 574 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
574 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 575 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
575 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 576 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
576 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 577 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
577 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 578 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
578 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 579 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
579 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 580 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
580 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 581 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
581 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 582 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
582 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 583 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
583 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 584 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
584 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 585 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
585 | cm_default = colorMenu->insertItem(tr("default")); | 586 | cm_default = colorMenu->insertItem(tr("default")); |
586 | 587 | ||
587 | #ifdef QT_QWS_OPIE | 588 | #ifdef QT_QWS_OPIE |
588 | 589 | ||
589 | colorMenu->insertItem(tr( "Custom")); | 590 | colorMenu->insertItem(tr( "Custom")); |
590 | #endif | 591 | #endif |
591 | 592 | ||
592 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 593 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
593 | 594 | ||
594 | sessionList = new QPopupMenu(this); | 595 | sessionList = new QPopupMenu(this); |
595 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 596 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, |
596 | SLOT(newSession()) ); | 597 | SLOT(newSession()) ); |
597 | 598 | ||
598 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 599 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
599 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 600 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
600 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 601 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
601 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 602 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
602 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 603 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
603 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 604 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
604 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 605 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
605 | 606 | ||
606 | menuBar->insertItem( tr("View"), configMenu ); | 607 | menuBar->insertItem( tr("View"), configMenu ); |
607 | menuBar->insertItem( tr("Fonts"), fontList ); | 608 | menuBar->insertItem( tr("Fonts"), fontList ); |
608 | menuBar->insertItem( tr("Sessions"), sessionList ); | 609 | menuBar->insertItem( tr("Sessions"), sessionList ); |
609 | 610 | ||
610 | toolBar = new QToolBar( this ); | 611 | toolBar = new QToolBar( this ); |
611 | 612 | ||
612 | QAction *a; | 613 | QAction *a; |
613 | 614 | ||
614 | // Button Commands | 615 | // Button Commands |
615 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); | 616 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
616 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
617 | a->addTo( toolBar ); | 618 | a->addTo( toolBar ); |
618 | 619 | ||
619 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 620 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
620 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 621 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
621 | a->addTo( toolBar ); | 622 | a->addTo( toolBar ); |
622 | 623 | ||
623 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 624 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
624 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 625 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
625 | a->addTo( toolBar ); | 626 | a->addTo( toolBar ); |
626 | 627 | ||
627 | 628 | ||
628 | /* | 629 | /* |
629 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 630 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
630 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 631 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
631 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 632 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
632 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 633 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
633 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 634 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
634 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 635 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
635 | */ | 636 | */ |
636 | /* | 637 | /* |
637 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 638 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
638 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 639 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
639 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 640 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
640 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 641 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
641 | */ | 642 | */ |
642 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 643 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
643 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 644 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
644 | a->addTo( toolBar ); | 645 | a->addTo( toolBar ); |
645 | 646 | ||
646 | secondToolBar = new QToolBar( this ); | 647 | secondToolBar = new QToolBar( this ); |
647 | secondToolBar->setHorizontalStretchable( TRUE ); | 648 | secondToolBar->setHorizontalStretchable( TRUE ); |
648 | 649 | ||
649 | commonCombo = new QComboBox( secondToolBar ); | 650 | commonCombo = new QComboBox( secondToolBar ); |
650 | // commonCombo->setMaximumWidth(236); | 651 | // commonCombo->setMaximumWidth(236); |
651 | 652 | ||
652 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 653 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
653 | if( listHidden) | 654 | if( listHidden) |
654 | { | 655 | { |
655 | secondToolBar->hide(); | 656 | secondToolBar->hide(); |
656 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 657 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
657 | } | 658 | } |
658 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 659 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
659 | 660 | ||
660 | cfg.setGroup("Commands"); | 661 | cfg.setGroup("Commands"); |
661 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 662 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
662 | 663 | ||
663 | initCommandList(); | 664 | initCommandList(); |
664 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 665 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
665 | // commonCombo->insertItem( commonCmds[i], i ); | 666 | // commonCombo->insertItem( commonCmds[i], i ); |
666 | // tmp = cfg.readEntry( QString::number(i),""); | 667 | // tmp = cfg.readEntry( QString::number(i),""); |
667 | // if(tmp != "") | 668 | // if(tmp != "") |
668 | // commonCombo->changeItem( tmp,i ); | 669 | // commonCombo->changeItem( tmp,i ); |
669 | // } | 670 | // } |
670 | 671 | ||
671 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 672 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
672 | 673 | ||
673 | sm_none = scrollMenu->insertItem(tr( "None" )); | 674 | sm_none = scrollMenu->insertItem(tr( "None" )); |
674 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 675 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
675 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 676 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
676 | // scrollMenu->insertSeparator(4); | 677 | // scrollMenu->insertSeparator(4); |
677 | // scrollMenu->insertItem(tr( "Horizontal" )); | 678 | // scrollMenu->insertItem(tr( "Horizontal" )); |
678 | 679 | ||
679 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 680 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
680 | 681 | ||
681 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 682 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
682 | 683 | ||
683 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 684 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
684 | cfg.setGroup("ScrollBar"); | 685 | cfg.setGroup("ScrollBar"); |
685 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 686 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
686 | 687 | ||
687 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 688 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
688 | cfg.setGroup("Menubar"); | 689 | cfg.setGroup("Menubar"); |
689 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 690 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
690 | 691 | ||
691 | fullscreen_msg = new QLabel(this); | 692 | fullscreen_msg = new QLabel(this); |
692 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 693 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
693 | fullscreen_msg-> hide(); | 694 | fullscreen_msg-> hide(); |
694 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 695 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
695 | fullscreen_msg-> setAutoResize(true); | 696 | fullscreen_msg-> setAutoResize(true); |
696 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 697 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
697 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 698 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
698 | 699 | ||
699 | fullscreen_timer = new QTimer(this); | 700 | fullscreen_timer = new QTimer(this); |
700 | connect(fullscreen_timer, SIGNAL(timeout()), | 701 | connect(fullscreen_timer, SIGNAL(timeout()), |
701 | this, SLOT(fullscreenTimeout())); | 702 | this, SLOT(fullscreenTimeout())); |
702 | show_fullscreen_msg = true; | 703 | show_fullscreen_msg = true; |
703 | 704 | ||
704 | //scrollMenuSelected(-29); | 705 | //scrollMenuSelected(-29); |
705 | // cfg.setGroup("ScrollBar"); | 706 | // cfg.setGroup("ScrollBar"); |
706 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 707 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
707 | // if(cfg.readNumEntry("Position",2) == 0) | 708 | // if(cfg.readNumEntry("Position",2) == 0) |
708 | // te->setScrollbarLocation(1); | 709 | // te->setScrollbarLocation(1); |
709 | // else | 710 | // else |
710 | // te->setScrollbarLocation(0); | 711 | // te->setScrollbarLocation(0); |
711 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 712 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
712 | // te->setWrapAt(120); | 713 | // te->setWrapAt(120); |
713 | // } | 714 | // } |
714 | // create applications ///////////////////////////////////////////////////// | 715 | // create applications ///////////////////////////////////////////////////// |
715 | setCentralWidget(tab); | 716 | setCentralWidget(tab); |
716 | 717 | ||
717 | // load keymaps //////////////////////////////////////////////////////////// | 718 | // load keymaps //////////////////////////////////////////////////////////// |
718 | KeyTrans::loadAll(); | 719 | KeyTrans::loadAll(); |
719 | for (int i = 0; i < KeyTrans::count(); i++) | 720 | for (int i = 0; i < KeyTrans::count(); i++) |
720 | { | 721 | { |
721 | KeyTrans* s = KeyTrans::find(i); | 722 | KeyTrans* s = KeyTrans::find(i); |
722 | assert( s ); | 723 | assert( s ); |
723 | } | 724 | } |
724 | 725 | ||
725 | se_pgm = _pgm; | 726 | se_pgm = _pgm; |
726 | se_args = _args; | 727 | se_args = _args; |
727 | 728 | ||
728 | cfg.setGroup("CommandLine"); | 729 | cfg.setGroup("CommandLine"); |
729 | 730 | ||
730 | if (cfg.hasKey("shell_args")) | 731 | if (cfg.hasKey("shell_args")) |
731 | { | 732 | { |
732 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 733 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
733 | for(uint i = 0; i < se_args_list.count(); i++) | 734 | for(uint i = 0; i < se_args_list.count(); i++) |
734 | { | 735 | { |
735 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 736 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
736 | } | 737 | } |
737 | } | 738 | } |
738 | else | 739 | else |
739 | { | 740 | { |
740 | se_args.prepend("--login"); | 741 | se_args.prepend("--login"); |
741 | } | 742 | } |
742 | 743 | ||
743 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 744 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
744 | 745 | ||
745 | // this is the "documentation" for those who know to look | 746 | // this is the "documentation" for those who know to look |
746 | if (! cfg.hasKey("shell_args")) | 747 | if (! cfg.hasKey("shell_args")) |
747 | { | 748 | { |
748 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 749 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
749 | } | 750 | } |
750 | if (! cfg.hasKey("shell_bin")) | 751 | if (! cfg.hasKey("shell_bin")) |
751 | { | 752 | { |
752 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 753 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
753 | } | 754 | } |
754 | 755 | ||
755 | parseCommandLine(); | 756 | parseCommandLine(); |
756 | 757 | ||
757 | // read and apply default values /////////////////////////////////////////// | 758 | // read and apply default values /////////////////////////////////////////// |
758 | resize(321, 321); // Dummy. | 759 | resize(321, 321); // Dummy. |
759 | QSize currentSize = size(); | 760 | QSize currentSize = size(); |
760 | if (currentSize != size()) | 761 | if (currentSize != size()) |
761 | defaultSize = size(); | 762 | defaultSize = size(); |
762 | 763 | ||
763 | 764 | ||
764 | /* allows us to catch cancel/escape */ | 765 | /* allows us to catch cancel/escape */ |
765 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 766 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
766 | QPoint ( 0, 0 )); | 767 | QPoint ( 0, 0 )); |
767 | } | 768 | } |
768 | 769 | ||
769 | void Konsole::show() | 770 | void Konsole::show() |
770 | { | 771 | { |
771 | if ( !nsessions ) | 772 | if ( !nsessions ) |
772 | { | 773 | { |
773 | newSession(); | 774 | newSession(); |
774 | } | 775 | } |
775 | QMainWindow::show(); | 776 | QMainWindow::show(); |
776 | 777 | ||
777 | } | 778 | } |
778 | 779 | ||
779 | void Konsole::initSession(const char*, QStrList &) | 780 | void Konsole::initSession(const char*, QStrList &) |
780 | { | 781 | { |
781 | QMainWindow::show(); | 782 | QMainWindow::show(); |
782 | } | 783 | } |
783 | 784 | ||
784 | Konsole::~Konsole() | 785 | Konsole::~Konsole() |
785 | { | 786 | { |
786 | while (nsessions > 0) | 787 | while (nsessions > 0) |
787 | { | 788 | { |
788 | doneSession(getTe(), 0); | 789 | doneSession(getTe(), 0); |
789 | } | 790 | } |
790 | } | 791 | } |
791 | 792 | ||
792 | void | 793 | void |
793 | Konsole::historyDialog() | 794 | Konsole::historyDialog() |
794 | { | 795 | { |
795 | QDialog *d = new QDialog ( this, "histdlg", true ); | 796 | QDialog *d = new QDialog ( this, "histdlg", true ); |
796 | // d-> setCaption ( tr( "History" )); | 797 | // d-> setCaption ( tr( "History" )); |
797 | 798 | ||
798 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 799 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
799 | 800 | ||
800 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 801 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
801 | lay-> addWidget ( l ); | 802 | lay-> addWidget ( l ); |
802 | 803 | ||
803 | Config cfg( "Konsole" ); | 804 | Config cfg( "Konsole" ); |
804 | cfg.setGroup("History"); | 805 | cfg.setGroup("History"); |
805 | int hist = cfg.readNumEntry("history_lines",300); | 806 | int hist = cfg.readNumEntry("history_lines",300); |
806 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 807 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
807 | 808 | ||
808 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 809 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
809 | spin-> setValue ( hist ); | 810 | spin-> setValue ( hist ); |
810 | spin-> setWrapping ( true ); | 811 | spin-> setWrapping ( true ); |
811 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 812 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
812 | lay-> addWidget ( spin ); | 813 | lay-> addWidget ( spin ); |
813 | 814 | ||
814 | if ( d-> exec ( ) == QDialog::Accepted ) | 815 | if ( d-> exec ( ) == QDialog::Accepted ) |
815 | { | 816 | { |
816 | cfg.writeEntry("history_lines", spin->value()); | 817 | cfg.writeEntry("history_lines", spin->value()); |
817 | cfg.writeEntry("avg_line_length", avg_line); | 818 | cfg.writeEntry("avg_line_length", avg_line); |
818 | if (getTe() != NULL) | 819 | if (getTe() != NULL) |
819 | { | 820 | { |
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index fe30b7e..b456ce2 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp | |||
@@ -1,29 +1,30 @@ | |||
1 | /* ---------------------------------------------------------------------- */ | 1 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [main.C] Konsole */ | 3 | /* [main.C] Konsole */ |
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. */ | 9 | /* This file is part of Konsole, an X terminal. */ |
10 | /* */ | 10 | /* */ |
11 | /* The material contained in here more or less directly orginates from */ | 11 | /* The material contained in here more or less directly orginates from */ |
12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 12 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
13 | /* */ | 13 | /* */ |
14 | /* ---------------------------------------------------------------------- */ | 14 | /* ---------------------------------------------------------------------- */ |
15 | /* */ | 15 | /* */ |
16 | /* Ported Konsole to Qt/Embedded */ | 16 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 17 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 19 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 20 | /* -------------------------------------------------------------------------- */ |
21 | 21 | ||
22 | #include "konsole.h" | 22 | #include "konsole.h" |
23 | 23 | ||
24 | #include <opie2/oapplicationfactory.h> | 24 | #include <opie2/oapplicationfactory.h> |
25 | 25 | ||
26 | 26 | ||
27 | /* --| main |------------------------------------------------------ */ | 27 | /* --| main |------------------------------------------------------ */ |
28 | using namespace Opie::Core; | ||
28 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) | 29 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) |
29 | 30 | ||
diff --git a/core/apps/helpbrowser/main.cpp b/core/apps/helpbrowser/main.cpp index c726cd3..66241ae 100644 --- a/core/apps/helpbrowser/main.cpp +++ b/core/apps/helpbrowser/main.cpp | |||
@@ -1,25 +1,26 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "helpbrowser.h" | 21 | #include "helpbrowser.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<HelpBrowser> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<HelpBrowser> ) |
diff --git a/core/apps/qcop/config.in b/core/apps/qcop/config.in index 2bd1a73..f99ff03 100644 --- a/core/apps/qcop/config.in +++ b/core/apps/qcop/config.in | |||
@@ -1,4 +1,4 @@ | |||
1 | config QCOP | 1 | config QCOP |
2 | boolean "opie-qcop (inter-application communication daemon)" | 2 | boolean "opie-qcop (inter-application communication client)" |
3 | default "y" | 3 | default "y" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | 4 | depends ( LIBQPE || LIBQPE-X11 ) |
diff --git a/core/apps/textedit/main.cpp b/core/apps/textedit/main.cpp index 9aee47b..d05d6d6 100644 --- a/core/apps/textedit/main.cpp +++ b/core/apps/textedit/main.cpp | |||
@@ -1,25 +1,26 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "textedit.h" | 21 | #include "textedit.h" |
22 | 22 | ||
23 | #include <opie2/oapplicationfactory.h> | 23 | #include <opie2/oapplicationfactory.h> |
24 | 24 | ||
25 | using namespace Opie::Core; | ||
25 | OPIE_EXPORT_APP( OApplicationFactory<TextEdit> ) | 26 | OPIE_EXPORT_APP( OApplicationFactory<TextEdit> ) |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index b54da34..5bb65a9 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,810 +1,808 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | #include "textedit.h" | 14 | #include "textedit.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | 17 | ||
18 | #include <opie2/ofileselector.h> | 18 | #include <opie2/ofileselector.h> |
19 | #include <opie2/ofiledialog.h> | 19 | #include <opie2/ofiledialog.h> |
20 | #include <opie2/ofontselector.h> | 20 | #include <opie2/ofontselector.h> |
21 | 21 | ||
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
25 | #include <qmenubar.h> | 25 | #include <qmenubar.h> |
26 | #include <qtoolbar.h> | 26 | #include <qtoolbar.h> |
27 | 27 | ||
28 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
29 | #include <qclipboard.h> | 29 | #include <qclipboard.h> |
30 | #include <qaction.h> | 30 | #include <qaction.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qmessagebox.h> | 32 | #include <qmessagebox.h> |
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
38 | #include <stdlib.h> //getenv | 38 | #include <stdlib.h> //getenv |
39 | 39 | ||
40 | using Opie::OFileDialog; | 40 | using namespace Opie::Ui; |
41 | using Opie::OFileSelector; | ||
42 | using Opie::OFontSelector; | ||
43 | 41 | ||
44 | #if QT_VERSION < 300 | 42 | #if QT_VERSION < 300 |
45 | 43 | ||
46 | class QpeEditor : public QMultiLineEdit | 44 | class QpeEditor : public QMultiLineEdit |
47 | { | 45 | { |
48 | 46 | ||
49 | public: | 47 | public: |
50 | QpeEditor( QWidget *parent, const char * name = 0 ) | 48 | QpeEditor( QWidget *parent, const char * name = 0 ) |
51 | : QMultiLineEdit( parent, name ) { | 49 | : QMultiLineEdit( parent, name ) { |
52 | clearTableFlags(); | 50 | clearTableFlags(); |
53 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 51 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
54 | } | 52 | } |
55 | 53 | ||
56 | void find( const QString &txt, bool caseSensitive, | 54 | void find( const QString &txt, bool caseSensitive, |
57 | bool backwards ); | 55 | bool backwards ); |
58 | protected: | 56 | protected: |
59 | bool markIt; | 57 | bool markIt; |
60 | int line1, line2, col1, col2; | 58 | int line1, line2, col1, col2; |
61 | void mousePressEvent( QMouseEvent * ); | 59 | void mousePressEvent( QMouseEvent * ); |
62 | void mouseReleaseEvent( QMouseEvent * ); | 60 | void mouseReleaseEvent( QMouseEvent * ); |
63 | 61 | ||
64 | //public slots: | 62 | //public slots: |
65 | /* | 63 | /* |
66 | signals: | 64 | signals: |
67 | void notFound(); | 65 | void notFound(); |
68 | void searchWrapped(); | 66 | void searchWrapped(); |
69 | */ | 67 | */ |
70 | 68 | ||
71 | private: | 69 | private: |
72 | 70 | ||
73 | }; | 71 | }; |
74 | 72 | ||
75 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 73 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
76 | switch(e->button()) { | 74 | switch(e->button()) { |
77 | case RightButton: | 75 | case RightButton: |
78 | { //rediculous workaround for qt popup menu | 76 | { //rediculous workaround for qt popup menu |
79 | //and the hold right click mechanism | 77 | //and the hold right click mechanism |
80 | this->setSelection( line1, col1, line2, col2); | 78 | this->setSelection( line1, col1, line2, col2); |
81 | QMultiLineEdit::mousePressEvent( e ); | 79 | QMultiLineEdit::mousePressEvent( e ); |
82 | markIt = false; | 80 | markIt = false; |
83 | } | 81 | } |
84 | break; | 82 | break; |
85 | default: | 83 | default: |
86 | { | 84 | { |
87 | if(!markIt) { | 85 | if(!markIt) { |
88 | int line, col; | 86 | int line, col; |
89 | this->getCursorPosition(&line, &col); | 87 | this->getCursorPosition(&line, &col); |
90 | line1=line2=line; | 88 | line1=line2=line; |
91 | col1=col2=col; | 89 | col1=col2=col; |
92 | } | 90 | } |
93 | QMultiLineEdit::mousePressEvent( e ); | 91 | QMultiLineEdit::mousePressEvent( e ); |
94 | } | 92 | } |
95 | break; | 93 | break; |
96 | }; | 94 | }; |
97 | } | 95 | } |
98 | 96 | ||
99 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 97 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
100 | if(this->hasMarkedText()) { | 98 | if(this->hasMarkedText()) { |
101 | markIt = true; | 99 | markIt = true; |
102 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 100 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
103 | } else { | 101 | } else { |
104 | markIt = false; | 102 | markIt = false; |
105 | } | 103 | } |
106 | } | 104 | } |
107 | 105 | ||
108 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 106 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
109 | bool backwards ) | 107 | bool backwards ) |
110 | { | 108 | { |
111 | static bool wrap = false; | 109 | static bool wrap = false; |
112 | int line, col; | 110 | int line, col; |
113 | if ( wrap ) { | 111 | if ( wrap ) { |
114 | if ( !backwards ) | 112 | if ( !backwards ) |
115 | line = col = 0; | 113 | line = col = 0; |
116 | wrap = false; | 114 | wrap = false; |
117 | // emit searchWrapped(); | 115 | // emit searchWrapped(); |
118 | } else { | 116 | } else { |
119 | getCursorPosition( &line, &col ); | 117 | getCursorPosition( &line, &col ); |
120 | } | 118 | } |
121 | //ignore backwards for now.... | 119 | //ignore backwards for now.... |
122 | if ( !backwards ) { | 120 | if ( !backwards ) { |
123 | for ( ; ; ) { | 121 | for ( ; ; ) { |
124 | if ( line >= numLines() ) { | 122 | if ( line >= numLines() ) { |
125 | wrap = true; | 123 | wrap = true; |
126 | //emit notFound(); | 124 | //emit notFound(); |
127 | break; | 125 | break; |
128 | } | 126 | } |
129 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 127 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
130 | if ( findCol >= 0 ) { | 128 | if ( findCol >= 0 ) { |
131 | setCursorPosition( line, findCol, false ); | 129 | setCursorPosition( line, findCol, false ); |
132 | col = findCol + txt.length(); | 130 | col = findCol + txt.length(); |
133 | setCursorPosition( line, col, true ); | 131 | setCursorPosition( line, col, true ); |
134 | 132 | ||
135 | //found = true; | 133 | //found = true; |
136 | break; | 134 | break; |
137 | } | 135 | } |
138 | line++; | 136 | line++; |
139 | col = 0; | 137 | col = 0; |
140 | } | 138 | } |
141 | } | 139 | } |
142 | } | 140 | } |
143 | 141 | ||
144 | 142 | ||
145 | #else | 143 | #else |
146 | 144 | ||
147 | #error "Must make a QpeEditor that inherits QTextEdit" | 145 | #error "Must make a QpeEditor that inherits QTextEdit" |
148 | 146 | ||
149 | #endif | 147 | #endif |
150 | 148 | ||
151 | 149 | ||
152 | static const int nfontsizes = 6; | 150 | static const int nfontsizes = 6; |
153 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 151 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
154 | 152 | ||
155 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 153 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
156 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 154 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
157 | { | 155 | { |
158 | doc = 0; | 156 | doc = 0; |
159 | edited=false; | 157 | edited=false; |
160 | fromSetDocument=false; | 158 | fromSetDocument=false; |
161 | 159 | ||
162 | setToolBarsMovable( false ); | 160 | setToolBarsMovable( false ); |
163 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 161 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
164 | 162 | ||
165 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 163 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
166 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 164 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
167 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 165 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
168 | 166 | ||
169 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 167 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
170 | 168 | ||
171 | QToolBar *bar = new QToolBar( this ); | 169 | QToolBar *bar = new QToolBar( this ); |
172 | bar->setHorizontalStretchable( true ); | 170 | bar->setHorizontalStretchable( true ); |
173 | menu = bar; | 171 | menu = bar; |
174 | 172 | ||
175 | QMenuBar *mb = new QMenuBar( bar ); | 173 | QMenuBar *mb = new QMenuBar( bar ); |
176 | QPopupMenu *file = new QPopupMenu( this ); | 174 | QPopupMenu *file = new QPopupMenu( this ); |
177 | QPopupMenu *edit = new QPopupMenu( this ); | 175 | QPopupMenu *edit = new QPopupMenu( this ); |
178 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 176 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
179 | 177 | ||
180 | font = new QPopupMenu( this ); | 178 | font = new QPopupMenu( this ); |
181 | 179 | ||
182 | bar = new QToolBar( this ); | 180 | bar = new QToolBar( this ); |
183 | editBar = bar; | 181 | editBar = bar; |
184 | 182 | ||
185 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 183 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
186 | QString::null, 0, this, 0 ); | 184 | QString::null, 0, this, 0 ); |
187 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 185 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
188 | // a->addTo( bar ); | 186 | // a->addTo( bar ); |
189 | a->addTo( file ); | 187 | a->addTo( file ); |
190 | 188 | ||
191 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 189 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
192 | QString::null, 0, this, 0 ); | 190 | QString::null, 0, this, 0 ); |
193 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 191 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
194 | a->addTo( bar ); | 192 | a->addTo( bar ); |
195 | a->addTo( file ); | 193 | a->addTo( file ); |
196 | 194 | ||
197 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 195 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
198 | QString::null, 0, this, 0 ); | 196 | QString::null, 0, this, 0 ); |
199 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 197 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
200 | file->insertSeparator(); | 198 | file->insertSeparator(); |
201 | a->addTo( bar ); | 199 | a->addTo( bar ); |
202 | a->addTo( file ); | 200 | a->addTo( file ); |
203 | 201 | ||
204 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 202 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
205 | QString::null, 0, this, 0 ); | 203 | QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 204 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
207 | a->addTo( file ); | 205 | a->addTo( file ); |
208 | 206 | ||
209 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 207 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
210 | QString::null, 0, this, 0 ); | 208 | QString::null, 0, this, 0 ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 209 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
212 | a->addTo( editBar ); | 210 | a->addTo( editBar ); |
213 | a->addTo( edit ); | 211 | a->addTo( edit ); |
214 | 212 | ||
215 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 213 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
216 | QString::null, 0, this, 0 ); | 214 | QString::null, 0, this, 0 ); |
217 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 215 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
218 | a->addTo( editBar ); | 216 | a->addTo( editBar ); |
219 | a->addTo( edit ); | 217 | a->addTo( edit ); |
220 | 218 | ||
221 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 219 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
222 | QString::null, 0, this, 0 ); | 220 | QString::null, 0, this, 0 ); |
223 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 221 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
224 | a->addTo( editBar ); | 222 | a->addTo( editBar ); |
225 | a->addTo( edit ); | 223 | a->addTo( edit ); |
226 | 224 | ||
227 | 225 | ||
228 | #ifndef QT_NO_CLIPBOARD | 226 | #ifndef QT_NO_CLIPBOARD |
229 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 227 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
230 | QString::null, 0, this, 0 ); | 228 | QString::null, 0, this, 0 ); |
231 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 229 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
232 | a->addTo( edit ); | 230 | a->addTo( edit ); |
233 | #endif | 231 | #endif |
234 | 232 | ||
235 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 233 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
236 | QString::null, 0, this, 0 ); | 234 | QString::null, 0, this, 0 ); |
237 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 235 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
238 | edit->insertSeparator(); | 236 | edit->insertSeparator(); |
239 | a->addTo( edit ); | 237 | a->addTo( edit ); |
240 | 238 | ||
241 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 239 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
242 | QString::null, 0, this, 0 ); | 240 | QString::null, 0, this, 0 ); |
243 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 241 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
244 | a->addTo( bar ); | 242 | a->addTo( bar ); |
245 | a->addTo( edit ); | 243 | a->addTo( edit ); |
246 | 244 | ||
247 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 245 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
248 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 246 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
249 | zin->addTo( font ); | 247 | zin->addTo( font ); |
250 | 248 | ||
251 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 249 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
252 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 250 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
253 | zout->addTo( font ); | 251 | zout->addTo( font ); |
254 | 252 | ||
255 | font->insertSeparator(); | 253 | font->insertSeparator(); |
256 | 254 | ||
257 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 255 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
258 | 256 | ||
259 | font->insertSeparator(); | 257 | font->insertSeparator(); |
260 | font->insertItem(tr("Advanced Features"), advancedMenu); | 258 | font->insertItem(tr("Advanced Features"), advancedMenu); |
261 | 259 | ||
262 | QAction *wa = new QAction( tr("Wrap lines"), | 260 | QAction *wa = new QAction( tr("Wrap lines"), |
263 | QString::null, 0, this, 0 ); | 261 | QString::null, 0, this, 0 ); |
264 | connect( wa, SIGNAL( toggled(bool) ), | 262 | connect( wa, SIGNAL( toggled(bool) ), |
265 | this, SLOT( setWordWrap(bool) ) ); | 263 | this, SLOT( setWordWrap(bool) ) ); |
266 | wa->setToggleAction(true); | 264 | wa->setToggleAction(true); |
267 | wa->addTo( advancedMenu); | 265 | wa->addTo( advancedMenu); |
268 | 266 | ||
269 | nStart = new QAction( tr("Start with new file"), | 267 | nStart = new QAction( tr("Start with new file"), |
270 | QString::null, 0, this, 0 ); | 268 | QString::null, 0, this, 0 ); |
271 | connect( nStart, SIGNAL( toggled(bool) ), | 269 | connect( nStart, SIGNAL( toggled(bool) ), |
272 | this, SLOT( changeStartConfig(bool) ) ); | 270 | this, SLOT( changeStartConfig(bool) ) ); |
273 | nStart->setToggleAction(true); | 271 | nStart->setToggleAction(true); |
274 | nStart->addTo( advancedMenu ); | 272 | nStart->addTo( advancedMenu ); |
275 | nStart->setEnabled(false); | 273 | nStart->setEnabled(false); |
276 | 274 | ||
277 | nAdvanced = new QAction( tr("Prompt on Exit"), | 275 | nAdvanced = new QAction( tr("Prompt on Exit"), |
278 | QString::null, 0, this, 0 ); | 276 | QString::null, 0, this, 0 ); |
279 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 277 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
280 | this, SLOT( doPrompt(bool) ) ); | 278 | this, SLOT( doPrompt(bool) ) ); |
281 | nAdvanced->setToggleAction(true); | 279 | nAdvanced->setToggleAction(true); |
282 | nAdvanced->addTo( advancedMenu ); | 280 | nAdvanced->addTo( advancedMenu ); |
283 | 281 | ||
284 | desktopAction = new QAction( tr("Always open linked file"), | 282 | desktopAction = new QAction( tr("Always open linked file"), |
285 | QString::null, 0, this, 0 ); | 283 | QString::null, 0, this, 0 ); |
286 | connect( desktopAction, SIGNAL( toggled(bool) ), | 284 | connect( desktopAction, SIGNAL( toggled(bool) ), |
287 | this, SLOT( doDesktop(bool) ) ); | 285 | this, SLOT( doDesktop(bool) ) ); |
288 | desktopAction->setToggleAction(true); | 286 | desktopAction->setToggleAction(true); |
289 | desktopAction->addTo( advancedMenu); | 287 | desktopAction->addTo( advancedMenu); |
290 | 288 | ||
291 | filePermAction = new QAction( tr("File Permissions"), | 289 | filePermAction = new QAction( tr("File Permissions"), |
292 | QString::null, 0, this, 0 ); | 290 | QString::null, 0, this, 0 ); |
293 | connect( filePermAction, SIGNAL( toggled(bool) ), | 291 | connect( filePermAction, SIGNAL( toggled(bool) ), |
294 | this, SLOT( doFilePerms(bool) ) ); | 292 | this, SLOT( doFilePerms(bool) ) ); |
295 | filePermAction->setToggleAction(true); | 293 | filePermAction->setToggleAction(true); |
296 | filePermAction->addTo( advancedMenu); | 294 | filePermAction->addTo( advancedMenu); |
297 | 295 | ||
298 | searchBarAction = new QAction( tr("Search Bar Open"), | 296 | searchBarAction = new QAction( tr("Search Bar Open"), |
299 | QString::null, 0, this, 0 ); | 297 | QString::null, 0, this, 0 ); |
300 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 298 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
301 | this, SLOT( setSearchBar(bool) ) ); | 299 | this, SLOT( setSearchBar(bool) ) ); |
302 | searchBarAction->setToggleAction(true); | 300 | searchBarAction->setToggleAction(true); |
303 | searchBarAction->addTo( advancedMenu); | 301 | searchBarAction->addTo( advancedMenu); |
304 | 302 | ||
305 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 303 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
306 | QString::null, 0, this, 0 ); | 304 | QString::null, 0, this, 0 ); |
307 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 305 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
308 | this, SLOT( doTimer(bool) ) ); | 306 | this, SLOT( doTimer(bool) ) ); |
309 | nAutoSave->setToggleAction(true); | 307 | nAutoSave->setToggleAction(true); |
310 | nAutoSave->addTo( advancedMenu); | 308 | nAutoSave->addTo( advancedMenu); |
311 | 309 | ||
312 | 310 | ||
313 | //font->insertSeparator(); | 311 | //font->insertSeparator(); |
314 | 312 | ||
315 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 313 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
316 | 314 | ||
317 | mb->insertItem( tr( "File" ), file ); | 315 | mb->insertItem( tr( "File" ), file ); |
318 | mb->insertItem( tr( "Edit" ), edit ); | 316 | mb->insertItem( tr( "Edit" ), edit ); |
319 | mb->insertItem( tr( "View" ), font ); | 317 | mb->insertItem( tr( "View" ), font ); |
320 | 318 | ||
321 | searchBar = new QToolBar(this); | 319 | searchBar = new QToolBar(this); |
322 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 320 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
323 | 321 | ||
324 | searchBar->setHorizontalStretchable( true ); | 322 | searchBar->setHorizontalStretchable( true ); |
325 | 323 | ||
326 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 324 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
327 | searchBar->setStretchableWidget( searchEdit ); | 325 | searchBar->setStretchableWidget( searchEdit ); |
328 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), | 326 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
329 | this, SLOT( search() ) ); | 327 | this, SLOT( search() ) ); |
330 | 328 | ||
331 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 329 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
332 | QString::null, 0, this, 0 ); | 330 | QString::null, 0, this, 0 ); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
334 | a->addTo( searchBar ); | 332 | a->addTo( searchBar ); |
335 | a->addTo( edit ); | 333 | a->addTo( edit ); |
336 | 334 | ||
337 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 335 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
338 | QString::null, 0, this, 0 ); | 336 | QString::null, 0, this, 0 ); |
339 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 337 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
340 | a->addTo( searchBar ); | 338 | a->addTo( searchBar ); |
341 | 339 | ||
342 | edit->insertSeparator(); | 340 | edit->insertSeparator(); |
343 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 341 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
344 | QString::null, 0, this, 0 ); | 342 | QString::null, 0, this, 0 ); |
345 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 343 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
346 | a->addTo( edit ); | 344 | a->addTo( edit ); |
347 | 345 | ||
348 | searchBar->hide(); | 346 | searchBar->hide(); |
349 | 347 | ||
350 | editor = new QpeEditor( this ); | 348 | editor = new QpeEditor( this ); |
351 | setCentralWidget( editor ); | 349 | setCentralWidget( editor ); |
352 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 350 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
353 | connect( editor, SIGNAL( textChanged() ), | 351 | connect( editor, SIGNAL( textChanged() ), |
354 | this, SLOT( editorChanged() ) ); | 352 | this, SLOT( editorChanged() ) ); |
355 | 353 | ||
356 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 354 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
357 | 355 | ||
358 | Config cfg("TextEdit"); | 356 | Config cfg("TextEdit"); |
359 | cfg. setGroup ( "Font" ); | 357 | cfg. setGroup ( "Font" ); |
360 | 358 | ||
361 | QFont defaultFont = editor-> font ( ); | 359 | QFont defaultFont = editor-> font ( ); |
362 | 360 | ||
363 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 361 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
364 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 362 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
365 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 363 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
366 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 364 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
367 | 365 | ||
368 | defaultFont = QFont ( family, size, weight, italic ); | 366 | defaultFont = QFont ( family, size, weight, italic ); |
369 | editor-> setFont ( defaultFont ); | 367 | editor-> setFont ( defaultFont ); |
370 | // updateCaption(); | 368 | // updateCaption(); |
371 | 369 | ||
372 | cfg.setGroup ( "View" ); | 370 | cfg.setGroup ( "View" ); |
373 | 371 | ||
374 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 372 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
375 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 373 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
376 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 374 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
377 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 375 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
378 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 376 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
379 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 377 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
380 | 378 | ||
381 | if(useSearchBar) searchBarAction->setOn(true); | 379 | if(useSearchBar) searchBarAction->setOn(true); |
382 | if(promptExit) nAdvanced->setOn( true ); | 380 | if(promptExit) nAdvanced->setOn( true ); |
383 | if(openDesktop) desktopAction->setOn( true ); | 381 | if(openDesktop) desktopAction->setOn( true ); |
384 | if(filePerms) filePermAction->setOn( true ); | 382 | if(filePerms) filePermAction->setOn( true ); |
385 | if(startWithNew) nStart->setOn( true ); | 383 | if(startWithNew) nStart->setOn( true ); |
386 | if(featureAutoSave) nAutoSave->setOn(true); | 384 | if(featureAutoSave) nAutoSave->setOn(true); |
387 | 385 | ||
388 | // { | 386 | // { |
389 | // doTimer(true); | 387 | // doTimer(true); |
390 | // } | 388 | // } |
391 | 389 | ||
392 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 390 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
393 | wa-> setOn ( wrap ); | 391 | wa-> setOn ( wrap ); |
394 | setWordWrap ( wrap ); | 392 | setWordWrap ( wrap ); |
395 | 393 | ||
396 | ///////////////// | 394 | ///////////////// |
397 | if( qApp->argc() > 1) { | 395 | if( qApp->argc() > 1) { |
398 | currentFileName=qApp->argv()[1]; | 396 | currentFileName=qApp->argv()[1]; |
399 | 397 | ||
400 | QFileInfo fi(currentFileName); | 398 | QFileInfo fi(currentFileName); |
401 | 399 | ||
402 | if(fi.baseName().left(1) == "") { | 400 | if(fi.baseName().left(1) == "") { |
403 | openDotFile(currentFileName); | 401 | openDotFile(currentFileName); |
404 | } else { | 402 | } else { |
405 | openFile(currentFileName); | 403 | openFile(currentFileName); |
406 | } | 404 | } |
407 | } else { | 405 | } else { |
408 | edited1=false; | 406 | edited1=false; |
409 | openDotFile(""); | 407 | openDotFile(""); |
410 | } | 408 | } |
411 | 409 | ||
412 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 410 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
413 | } | 411 | } |
414 | 412 | ||
415 | TextEdit::~TextEdit() { | 413 | TextEdit::~TextEdit() { |
416 | qWarning("textedit d'tor"); | 414 | qWarning("textedit d'tor"); |
417 | delete editor; | 415 | delete editor; |
418 | } | 416 | } |
419 | 417 | ||
420 | void TextEdit::closeEvent(QCloseEvent *) { | 418 | void TextEdit::closeEvent(QCloseEvent *) { |
421 | if( edited1 && promptExit) | 419 | if( edited1 && promptExit) |
422 | { | 420 | { |
423 | switch( savePrompt() ) | 421 | switch( savePrompt() ) |
424 | { | 422 | { |
425 | case 1: | 423 | case 1: |
426 | { | 424 | { |
427 | saveAs(); | 425 | saveAs(); |
428 | qApp->quit(); | 426 | qApp->quit(); |
429 | } | 427 | } |
430 | break; | 428 | break; |
431 | 429 | ||
432 | case 2: | 430 | case 2: |
433 | { | 431 | { |
434 | qApp->quit(); | 432 | qApp->quit(); |
435 | } | 433 | } |
436 | break; | 434 | break; |
437 | 435 | ||
438 | case -1: | 436 | case -1: |
439 | break; | 437 | break; |
440 | }; | 438 | }; |
441 | } | 439 | } |
442 | else | 440 | else |
443 | qApp->quit(); | 441 | qApp->quit(); |
444 | 442 | ||
445 | } | 443 | } |
446 | 444 | ||
447 | void TextEdit::cleanUp() { | 445 | void TextEdit::cleanUp() { |
448 | 446 | ||
449 | Config cfg ( "TextEdit" ); | 447 | Config cfg ( "TextEdit" ); |
450 | cfg. setGroup ( "Font" ); | 448 | cfg. setGroup ( "Font" ); |
451 | QFont f = editor->font(); | 449 | QFont f = editor->font(); |
452 | cfg.writeEntry ( "Family", f. family ( )); | 450 | cfg.writeEntry ( "Family", f. family ( )); |
453 | cfg.writeEntry ( "Size", f. pointSize ( )); | 451 | cfg.writeEntry ( "Size", f. pointSize ( )); |
454 | cfg.writeEntry ( "Weight", f. weight ( )); | 452 | cfg.writeEntry ( "Weight", f. weight ( )); |
455 | cfg.writeEntry ( "Italic", f. italic ( )); | 453 | cfg.writeEntry ( "Italic", f. italic ( )); |
456 | 454 | ||
457 | cfg.setGroup ( "View" ); | 455 | cfg.setGroup ( "View" ); |
458 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 456 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
459 | cfg.writeEntry ( "FileView", viewSelection ); | 457 | cfg.writeEntry ( "FileView", viewSelection ); |
460 | 458 | ||
461 | cfg.writeEntry ( "PromptExit", promptExit ); | 459 | cfg.writeEntry ( "PromptExit", promptExit ); |
462 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 460 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
463 | cfg.writeEntry ( "FilePermissions", filePerms ); | 461 | cfg.writeEntry ( "FilePermissions", filePerms ); |
464 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 462 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
465 | cfg.writeEntry ( "startNew", startWithNew ); | 463 | cfg.writeEntry ( "startNew", startWithNew ); |
466 | 464 | ||
467 | } | 465 | } |
468 | 466 | ||
469 | 467 | ||
470 | void TextEdit::accept() { | 468 | void TextEdit::accept() { |
471 | if( edited1) | 469 | if( edited1) |
472 | saveAs(); | 470 | saveAs(); |
473 | qApp->quit(); | 471 | qApp->quit(); |
474 | } | 472 | } |
475 | 473 | ||
476 | void TextEdit::zoomIn() { | 474 | void TextEdit::zoomIn() { |
477 | setFontSize(editor->font().pointSize()+1,false); | 475 | setFontSize(editor->font().pointSize()+1,false); |
478 | } | 476 | } |
479 | 477 | ||
480 | void TextEdit::zoomOut() { | 478 | void TextEdit::zoomOut() { |
481 | setFontSize(editor->font().pointSize()-1,true); | 479 | setFontSize(editor->font().pointSize()-1,true); |
482 | } | 480 | } |
483 | 481 | ||
484 | 482 | ||
485 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 483 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
486 | int s=10; | 484 | int s=10; |
487 | for (int i=0; i<nfontsizes; i++) { | 485 | for (int i=0; i<nfontsizes; i++) { |
488 | if ( fontsize[i] == sz ) { | 486 | if ( fontsize[i] == sz ) { |
489 | s = sz; | 487 | s = sz; |
490 | break; | 488 | break; |
491 | } else if ( round_down_not_up ) { | 489 | } else if ( round_down_not_up ) { |
492 | if ( fontsize[i] < sz ) | 490 | if ( fontsize[i] < sz ) |
493 | s = fontsize[i]; | 491 | s = fontsize[i]; |
494 | } else { | 492 | } else { |
495 | if ( fontsize[i] > sz ) { | 493 | if ( fontsize[i] > sz ) { |
496 | s = fontsize[i]; | 494 | s = fontsize[i]; |
497 | break; | 495 | break; |
498 | } | 496 | } |
499 | } | 497 | } |
500 | } | 498 | } |
501 | 499 | ||
502 | QFont f = editor->font(); | 500 | QFont f = editor->font(); |
503 | f.setPointSize(s); | 501 | f.setPointSize(s); |
504 | editor->setFont(f); | 502 | editor->setFont(f); |
505 | 503 | ||
506 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 504 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
507 | zout->setEnabled(s != fontsize[0]); | 505 | zout->setEnabled(s != fontsize[0]); |
508 | } | 506 | } |
509 | 507 | ||
510 | void TextEdit::setBold(bool y) { | 508 | void TextEdit::setBold(bool y) { |
511 | QFont f = editor->font(); | 509 | QFont f = editor->font(); |
512 | f.setBold(y); | 510 | f.setBold(y); |
513 | editor->setFont(f); | 511 | editor->setFont(f); |
514 | } | 512 | } |
515 | 513 | ||
516 | void TextEdit::setItalic(bool y) { | 514 | void TextEdit::setItalic(bool y) { |
517 | QFont f = editor->font(); | 515 | QFont f = editor->font(); |
518 | f.setItalic(y); | 516 | f.setItalic(y); |
519 | editor->setFont(f); | 517 | editor->setFont(f); |
520 | } | 518 | } |
521 | 519 | ||
522 | void TextEdit::setWordWrap(bool y) { | 520 | void TextEdit::setWordWrap(bool y) { |
523 | bool state = editor->edited(); | 521 | bool state = editor->edited(); |
524 | QString captionStr = caption(); | 522 | QString captionStr = caption(); |
525 | bool b1 = edited1; | 523 | bool b1 = edited1; |
526 | bool b2 = edited; | 524 | bool b2 = edited; |
527 | 525 | ||
528 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 526 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
529 | editor->setEdited( state ); | 527 | editor->setEdited( state ); |
530 | edited1=b1; | 528 | edited1=b1; |
531 | edited=b2; | 529 | edited=b2; |
532 | setCaption(captionStr); | 530 | setCaption(captionStr); |
533 | } | 531 | } |
534 | 532 | ||
535 | void TextEdit::setSearchBar(bool b) { | 533 | void TextEdit::setSearchBar(bool b) { |
536 | useSearchBar=b; | 534 | useSearchBar=b; |
537 | Config cfg("TextEdit"); | 535 | Config cfg("TextEdit"); |
538 | cfg.setGroup("View"); | 536 | cfg.setGroup("View"); |
539 | cfg.writeEntry ( "SearchBar", b ); | 537 | cfg.writeEntry ( "SearchBar", b ); |
540 | searchBarAction->setOn(b); | 538 | searchBarAction->setOn(b); |
541 | if(b) | 539 | if(b) |
542 | searchBar->show(); | 540 | searchBar->show(); |
543 | else | 541 | else |
544 | searchBar->hide(); | 542 | searchBar->hide(); |
545 | editor->setFocus(); | 543 | editor->setFocus(); |
546 | } | 544 | } |
547 | 545 | ||
548 | void TextEdit::fileNew() { | 546 | void TextEdit::fileNew() { |
549 | // if( !bFromDocView ) { | 547 | // if( !bFromDocView ) { |
550 | // saveAs(); | 548 | // saveAs(); |
551 | // } | 549 | // } |
552 | newFile(DocLnk()); | 550 | newFile(DocLnk()); |
553 | } | 551 | } |
554 | 552 | ||
555 | void TextEdit::fileOpen() { | 553 | void TextEdit::fileOpen() { |
556 | Config cfg("TextEdit"); | 554 | Config cfg("TextEdit"); |
557 | cfg. setGroup ( "View" ); | 555 | cfg. setGroup ( "View" ); |
558 | QMap<QString, QStringList> map; | 556 | QMap<QString, QStringList> map; |
559 | map.insert(tr("All"), QStringList() ); | 557 | map.insert(tr("All"), QStringList() ); |
560 | QStringList text; | 558 | QStringList text; |
561 | text << "text/*"; | 559 | text << "text/*"; |
562 | map.insert(tr("Text"), text ); | 560 | map.insert(tr("Text"), text ); |
563 | text << "*"; | 561 | text << "*"; |
564 | map.insert(tr("All"), text ); | 562 | map.insert(tr("All"), text ); |
565 | QString str = OFileDialog::getOpenFileName( 2, | 563 | QString str = OFileDialog::getOpenFileName( 2, |
566 | QString::null , | 564 | QString::null , |
567 | QString::null, map); | 565 | QString::null, map); |
568 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 566 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
569 | { | 567 | { |
570 | openFile( str ); | 568 | openFile( str ); |
571 | } | 569 | } |
572 | else | 570 | else |
573 | updateCaption(); | 571 | updateCaption(); |
574 | } | 572 | } |
575 | 573 | ||
576 | void TextEdit::doSearchBar() { | 574 | void TextEdit::doSearchBar() { |
577 | if(!useSearchBar) | 575 | if(!useSearchBar) |
578 | searchBar->hide(); | 576 | searchBar->hide(); |
579 | else | 577 | else |
580 | searchBar->show(); | 578 | searchBar->show(); |
581 | } | 579 | } |
582 | 580 | ||
583 | #if 0 | 581 | #if 0 |
584 | void TextEdit::slotFind() { | 582 | void TextEdit::slotFind() { |
585 | FindDialog frmFind( tr("Text Editor"), this ); | 583 | FindDialog frmFind( tr("Text Editor"), this ); |
586 | connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), | 584 | connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), |
587 | editor, SLOT(slotDoFind(const QString&,bool,bool))); | 585 | editor, SLOT(slotDoFind(const QString&,bool,bool))); |
588 | 586 | ||
589 | //case sensitive, backwards, [category] | 587 | //case sensitive, backwards, [category] |
590 | 588 | ||
591 | connect( editor, SIGNAL(notFound()), | 589 | connect( editor, SIGNAL(notFound()), |
592 | &frmFind, SLOT(slotNotFound()) ); | 590 | &frmFind, SLOT(slotNotFound()) ); |
593 | connect( editor, SIGNAL(searchWrapped()), | 591 | connect( editor, SIGNAL(searchWrapped()), |
594 | &frmFind, SLOT(slotWrapAround()) ); | 592 | &frmFind, SLOT(slotWrapAround()) ); |
595 | 593 | ||
596 | frmFind.exec(); | 594 | frmFind.exec(); |
597 | 595 | ||
598 | 596 | ||
599 | } | 597 | } |
600 | #endif | 598 | #endif |
601 | 599 | ||
602 | void TextEdit::fileRevert() { | 600 | void TextEdit::fileRevert() { |
603 | clear(); | 601 | clear(); |
604 | fileOpen(); | 602 | fileOpen(); |
605 | } | 603 | } |
606 | 604 | ||
607 | void TextEdit::editCut() { | 605 | void TextEdit::editCut() { |
608 | #ifndef QT_NO_CLIPBOARD | 606 | #ifndef QT_NO_CLIPBOARD |
609 | editor->cut(); | 607 | editor->cut(); |
610 | #endif | 608 | #endif |
611 | } | 609 | } |
612 | 610 | ||
613 | void TextEdit::editCopy() { | 611 | void TextEdit::editCopy() { |
614 | #ifndef QT_NO_CLIPBOARD | 612 | #ifndef QT_NO_CLIPBOARD |
615 | editor->copy(); | 613 | editor->copy(); |
616 | #endif | 614 | #endif |
617 | } | 615 | } |
618 | 616 | ||
619 | void TextEdit::editPaste() { | 617 | void TextEdit::editPaste() { |
620 | #ifndef QT_NO_CLIPBOARD | 618 | #ifndef QT_NO_CLIPBOARD |
621 | editor->paste(); | 619 | editor->paste(); |
622 | #endif | 620 | #endif |
623 | } | 621 | } |
624 | 622 | ||
625 | void TextEdit::editFind() { | 623 | void TextEdit::editFind() { |
626 | searchBar->show(); | 624 | searchBar->show(); |
627 | searchEdit->setFocus(); | 625 | searchEdit->setFocus(); |
628 | } | 626 | } |
629 | 627 | ||
630 | void TextEdit::findNext() { | 628 | void TextEdit::findNext() { |
631 | editor->find( searchEdit->text(), false, false ); | 629 | editor->find( searchEdit->text(), false, false ); |
632 | 630 | ||
633 | } | 631 | } |
634 | 632 | ||
635 | void TextEdit::findClose() { | 633 | void TextEdit::findClose() { |
636 | searchBar->hide(); | 634 | searchBar->hide(); |
637 | } | 635 | } |
638 | 636 | ||
639 | void TextEdit::search() { | 637 | void TextEdit::search() { |
640 | editor->find( searchEdit->text(), false, false ); | 638 | editor->find( searchEdit->text(), false, false ); |
641 | } | 639 | } |
642 | 640 | ||
643 | void TextEdit::newFile( const DocLnk &f ) { | 641 | void TextEdit::newFile( const DocLnk &f ) { |
644 | DocLnk nf = f; | 642 | DocLnk nf = f; |
645 | nf.setType("text/plain"); | 643 | nf.setType("text/plain"); |
646 | clear(); | 644 | clear(); |
647 | setWState (WState_Reserved1 ); | 645 | setWState (WState_Reserved1 ); |
648 | editor->setFocus(); | 646 | editor->setFocus(); |
649 | doc = new DocLnk(nf); | 647 | doc = new DocLnk(nf); |
650 | currentFileName = "Unnamed"; | 648 | currentFileName = "Unnamed"; |
651 | qDebug("newFile "+currentFileName); | 649 | qDebug("newFile "+currentFileName); |
652 | updateCaption( currentFileName); | 650 | updateCaption( currentFileName); |
653 | // editor->setEdited( false); | 651 | // editor->setEdited( false); |
654 | } | 652 | } |
655 | 653 | ||
656 | void TextEdit::openDotFile( const QString &f ) { | 654 | void TextEdit::openDotFile( const QString &f ) { |
657 | if(!currentFileName.isEmpty()) { | 655 | if(!currentFileName.isEmpty()) { |
658 | currentFileName=f; | 656 | currentFileName=f; |
659 | 657 | ||
660 | qDebug("openFile dotfile " + currentFileName); | 658 | qDebug("openFile dotfile " + currentFileName); |
661 | QString txt; | 659 | QString txt; |
662 | QFile file(f); | 660 | QFile file(f); |
663 | file.open(IO_ReadWrite); | 661 | file.open(IO_ReadWrite); |
664 | QTextStream t(&file); | 662 | QTextStream t(&file); |
665 | while ( !t.atEnd()) { | 663 | while ( !t.atEnd()) { |
666 | txt+=t.readLine()+"\n"; | 664 | txt+=t.readLine()+"\n"; |
667 | } | 665 | } |
668 | editor->setText(txt); | 666 | editor->setText(txt); |
669 | editor->setEdited( false); | 667 | editor->setEdited( false); |
670 | edited1=false; | 668 | edited1=false; |
671 | edited=false; | 669 | edited=false; |
672 | 670 | ||
673 | 671 | ||
674 | } | 672 | } |
675 | updateCaption( currentFileName); | 673 | updateCaption( currentFileName); |
676 | } | 674 | } |
677 | 675 | ||
678 | void TextEdit::openFile( const QString &f ) { | 676 | void TextEdit::openFile( const QString &f ) { |
679 | qDebug("filename is "+ f); | 677 | qDebug("filename is "+ f); |
680 | QString filer; | 678 | QString filer; |
681 | QFileInfo fi( f); | 679 | QFileInfo fi( f); |
682 | // bFromDocView = true; | 680 | // bFromDocView = true; |
683 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 681 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
684 | { | 682 | { |
685 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 683 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
686 | { | 684 | { |
687 | case 0: //desktop | 685 | case 0: //desktop |
688 | filer = f; | 686 | filer = f; |
689 | break; | 687 | break; |
690 | case 1: //linked | 688 | case 1: //linked |
691 | DocLnk sf(f); | 689 | DocLnk sf(f); |
692 | filer = sf.file(); | 690 | filer = sf.file(); |
693 | break; | 691 | break; |
694 | }; | 692 | }; |
695 | } | 693 | } |
696 | else if(fi.baseName().left(1) == "") | 694 | else if(fi.baseName().left(1) == "") |
697 | { | 695 | { |
698 | qDebug("opening dotfile"); | 696 | qDebug("opening dotfile"); |
699 | currentFileName=f; | 697 | currentFileName=f; |
700 | openDotFile(currentFileName); | 698 | openDotFile(currentFileName); |
701 | return; | 699 | return; |
702 | } | 700 | } |
703 | /* | 701 | /* |
704 | * The problem is a file where Config(f).isValid() and it does not | 702 | * The problem is a file where Config(f).isValid() and it does not |
705 | * end with .desktop will be treated as desktop file | 703 | * end with .desktop will be treated as desktop file |
706 | */ | 704 | */ |
707 | else if (f.find(".desktop",0,true) != -1 ) | 705 | else if (f.find(".desktop",0,true) != -1 ) |
708 | { | 706 | { |
709 | DocLnk sf(f); | 707 | DocLnk sf(f); |
710 | filer = sf.file(); | 708 | filer = sf.file(); |
711 | if(filer.right(1) == "/") | 709 | if(filer.right(1) == "/") |
712 | filer = f; | 710 | filer = f; |
713 | 711 | ||
714 | } | 712 | } |
715 | else | 713 | else |
716 | filer = f; | 714 | filer = f; |
717 | 715 | ||
718 | DocLnk nf; | 716 | DocLnk nf; |
719 | nf.setType("text/plain"); | 717 | nf.setType("text/plain"); |
720 | nf.setFile(filer); | 718 | nf.setFile(filer); |
721 | currentFileName=filer; | 719 | currentFileName=filer; |
722 | 720 | ||
723 | nf.setName(fi.baseName()); | 721 | nf.setName(fi.baseName()); |
724 | openFile(nf); | 722 | openFile(nf); |
725 | 723 | ||
726 | qDebug("openFile string "+currentFileName); | 724 | qDebug("openFile string "+currentFileName); |
727 | 725 | ||
728 | showEditTools(); | 726 | showEditTools(); |
729 | // Show filename in caption | 727 | // Show filename in caption |
730 | QString name = filer; | 728 | QString name = filer; |
731 | int sep = name.findRev( '/' ); | 729 | int sep = name.findRev( '/' ); |
732 | if ( sep > 0 ) | 730 | if ( sep > 0 ) |
733 | name = name.mid( sep+1 ); | 731 | name = name.mid( sep+1 ); |
734 | updateCaption( name ); | 732 | updateCaption( name ); |
735 | } | 733 | } |
736 | 734 | ||
737 | void TextEdit::openFile( const DocLnk &f ) { | 735 | void TextEdit::openFile( const DocLnk &f ) { |
738 | // clear(); | 736 | // clear(); |
739 | // bFromDocView = true; | 737 | // bFromDocView = true; |
740 | FileManager fm; | 738 | FileManager fm; |
741 | QString txt; | 739 | QString txt; |
742 | currentFileName=f.file(); | 740 | currentFileName=f.file(); |
743 | qDebug("openFile doclnk " + currentFileName); | 741 | qDebug("openFile doclnk " + currentFileName); |
744 | if ( !fm.loadFile( f, txt ) ) { | 742 | if ( !fm.loadFile( f, txt ) ) { |
745 | // ####### could be a new file | 743 | // ####### could be a new file |
746 | qDebug( "Cannot open file" ); | 744 | qDebug( "Cannot open file" ); |
747 | } | 745 | } |
748 | // fileNew(); | 746 | // fileNew(); |
749 | if ( doc ) | 747 | if ( doc ) |
750 | delete doc; | 748 | delete doc; |
751 | doc = new DocLnk(f); | 749 | doc = new DocLnk(f); |
752 | editor->setText(txt); | 750 | editor->setText(txt); |
753 | editor->setEdited( false); | 751 | editor->setEdited( false); |
754 | edited1=false; | 752 | edited1=false; |
755 | edited=false; | 753 | edited=false; |
756 | 754 | ||
757 | doc->setName(currentFileName); | 755 | doc->setName(currentFileName); |
758 | updateCaption(); | 756 | updateCaption(); |
759 | setTimer(); | 757 | setTimer(); |
760 | } | 758 | } |
761 | 759 | ||
762 | void TextEdit::showEditTools() { | 760 | void TextEdit::showEditTools() { |
763 | menu->show(); | 761 | menu->show(); |
764 | editBar->show(); | 762 | editBar->show(); |
765 | if(!useSearchBar) | 763 | if(!useSearchBar) |
766 | searchBar->hide(); | 764 | searchBar->hide(); |
767 | else | 765 | else |
768 | searchBar->show(); | 766 | searchBar->show(); |
769 | setWState (WState_Reserved1 ); | 767 | setWState (WState_Reserved1 ); |
770 | } | 768 | } |
771 | 769 | ||
772 | /*! | 770 | /*! |
773 | unprompted save */ | 771 | unprompted save */ |
774 | bool TextEdit::save() { | 772 | bool TextEdit::save() { |
775 | qDebug("saveAsFile " + currentFileName); | 773 | qDebug("saveAsFile " + currentFileName); |
776 | if(currentFileName.isEmpty()) { | 774 | if(currentFileName.isEmpty()) { |
777 | saveAs(); | 775 | saveAs(); |
778 | return false; | 776 | return false; |
779 | } | 777 | } |
780 | 778 | ||
781 | QString file = doc->file(); | 779 | QString file = doc->file(); |
782 | qDebug("saver file "+file); | 780 | qDebug("saver file "+file); |
783 | QString name= doc->name(); | 781 | QString name= doc->name(); |
784 | qDebug("File named "+name); | 782 | qDebug("File named "+name); |
785 | QString rt = editor->text(); | 783 | QString rt = editor->text(); |
786 | if( !rt.isEmpty() ) { | 784 | if( !rt.isEmpty() ) { |
787 | if(name.isEmpty()) { | 785 | if(name.isEmpty()) { |
788 | saveAs(); | 786 | saveAs(); |
789 | } else { | 787 | } else { |
790 | currentFileName= name ; | 788 | currentFileName= name ; |
791 | qDebug("saveFile "+currentFileName); | 789 | qDebug("saveFile "+currentFileName); |
792 | 790 | ||
793 | struct stat buf; | 791 | struct stat buf; |
794 | mode_t mode; | 792 | mode_t mode; |
795 | stat(file.latin1(), &buf); | 793 | stat(file.latin1(), &buf); |
796 | mode = buf.st_mode; | 794 | mode = buf.st_mode; |
797 | 795 | ||
798 | if(!fileIs) { | 796 | if(!fileIs) { |
799 | doc->setName( name); | 797 | doc->setName( name); |
800 | FileManager fm; | 798 | FileManager fm; |
801 | if ( !fm.saveFile( *doc, rt ) ) { | 799 | if ( !fm.saveFile( *doc, rt ) ) { |
802 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 800 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
803 | return false; | 801 | return false; |
804 | } | 802 | } |
805 | } else { | 803 | } else { |
806 | qDebug("regular save file"); | 804 | qDebug("regular save file"); |
807 | QFile f(file); | 805 | QFile f(file); |
808 | if( f.open(IO_WriteOnly)) { | 806 | if( f.open(IO_WriteOnly)) { |
809 | QCString crt = rt.utf8(); | 807 | QCString crt = rt.utf8(); |
810 | f.writeBlock(crt,crt.length()); | 808 | f.writeBlock(crt,crt.length()); |
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h index 34f3617..6cc693f 100644 --- a/core/apps/textedit/textedit.h +++ b/core/apps/textedit/textedit.h | |||
@@ -1,143 +1,143 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 | 20 | // additions made by L.J. Potter Sun 02-17-2002 22:27:46 |
21 | 21 | ||
22 | #ifndef TEXTEDIT_H | 22 | #ifndef TEXTEDIT_H |
23 | #define TEXTEDIT_H | 23 | #define TEXTEDIT_H |
24 | 24 | ||
25 | #define QTEXTEDIT_OPEN_API | 25 | #define QTEXTEDIT_OPEN_API |
26 | 26 | ||
27 | //#include "fileBrowser.h" | 27 | //#include "fileBrowser.h" |
28 | //#include "fileSaver.h" | 28 | //#include "fileSaver.h" |
29 | 29 | ||
30 | #include <qpe/filemanager.h> | 30 | #include <qpe/filemanager.h> |
31 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
32 | 32 | ||
33 | //#include <opie/ofileselector.h> | 33 | //#include <opie2/ofileselector.h> |
34 | 34 | ||
35 | #include <qmainwindow.h> | 35 | #include <qmainwindow.h> |
36 | #include <qmultilineedit.h> | 36 | #include <qmultilineedit.h> |
37 | #include <qlist.h> | 37 | #include <qlist.h> |
38 | #include <qmap.h> | 38 | #include <qmap.h> |
39 | 39 | ||
40 | class QAction; | 40 | class QAction; |
41 | class QWidgetStack; | 41 | class QWidgetStack; |
42 | class QToolButton; | 42 | class QToolButton; |
43 | class QPopupMenu; | 43 | class QPopupMenu; |
44 | class QToolBar; | 44 | class QToolBar; |
45 | class QLineEdit; | 45 | class QLineEdit; |
46 | class QAction; | 46 | class QAction; |
47 | class FileSelector; | 47 | class FileSelector; |
48 | class QpeEditor; | 48 | class QpeEditor; |
49 | class QPopupMenu; | 49 | class QPopupMenu; |
50 | class QTimer; | 50 | class QTimer; |
51 | 51 | ||
52 | class TextEdit : public QMainWindow | 52 | class TextEdit : public QMainWindow |
53 | { | 53 | { |
54 | Q_OBJECT | 54 | Q_OBJECT |
55 | 55 | ||
56 | public: | 56 | public: |
57 | static QString appName() { return QString::fromLatin1("textedit"); } | 57 | static QString appName() { return QString::fromLatin1("textedit"); } |
58 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 58 | TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
59 | ~TextEdit(); | 59 | ~TextEdit(); |
60 | 60 | ||
61 | protected: | 61 | protected: |
62 | QPopupMenu *font; | 62 | QPopupMenu *font; |
63 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; | 63 | QAction *nStart, *nFileDlgOpt, *nAdvanced, *desktopAction, *filePermAction, *searchBarAction, *nAutoSave; |
64 | bool edited, edited1; | 64 | bool edited, edited1; |
65 | void openFile( const QString & ); | 65 | void openFile( const QString & ); |
66 | QCopChannel * channel; | 66 | QCopChannel * channel; |
67 | 67 | ||
68 | bool featureAutoSave; | 68 | bool featureAutoSave; |
69 | void closeEvent( QCloseEvent *e ); | 69 | void closeEvent( QCloseEvent *e ); |
70 | void doSearchBar(); | 70 | void doSearchBar(); |
71 | int savePrompt(); | 71 | int savePrompt(); |
72 | void setTimer(); | 72 | void setTimer(); |
73 | private slots: | 73 | private slots: |
74 | void editorChanged(); | 74 | void editorChanged(); |
75 | void receive(const QCString&, const QByteArray&); | 75 | void receive(const QCString&, const QByteArray&); |
76 | void timerCrank(); | 76 | void timerCrank(); |
77 | void doTimer(bool); | 77 | void doTimer(bool); |
78 | void editPasteTimeDate(); | 78 | void editPasteTimeDate(); |
79 | void doPrompt(bool); | 79 | void doPrompt(bool); |
80 | void doDesktop(bool); | 80 | void doDesktop(bool); |
81 | void doFilePerms(bool); | 81 | void doFilePerms(bool); |
82 | void doAbout(); | 82 | void doAbout(); |
83 | void setDocument(const QString&); | 83 | void setDocument(const QString&); |
84 | void changeFont(); | 84 | void changeFont(); |
85 | void fileNew(); | 85 | void fileNew(); |
86 | void fileRevert(); | 86 | void fileRevert(); |
87 | void fileOpen(); | 87 | void fileOpen(); |
88 | void changeStartConfig(bool); | 88 | void changeStartConfig(bool); |
89 | bool save(); | 89 | bool save(); |
90 | bool saveAs(); | 90 | bool saveAs(); |
91 | void cleanUp(); | 91 | void cleanUp(); |
92 | 92 | ||
93 | void gotoLine(); | 93 | void gotoLine(); |
94 | void doGoto(); | 94 | void doGoto(); |
95 | 95 | ||
96 | 96 | ||
97 | void editCut(); | 97 | void editCut(); |
98 | void editCopy(); | 98 | void editCopy(); |
99 | void editPaste(); | 99 | void editPaste(); |
100 | void editFind(); | 100 | void editFind(); |
101 | void editDelete(); | 101 | void editDelete(); |
102 | 102 | ||
103 | void findNext(); | 103 | void findNext(); |
104 | void findClose(); | 104 | void findClose(); |
105 | 105 | ||
106 | void search(); | 106 | void search(); |
107 | void accept(); | 107 | void accept(); |
108 | 108 | ||
109 | void newFile( const DocLnk & ); | 109 | void newFile( const DocLnk & ); |
110 | void openFile( const DocLnk & ); | 110 | void openFile( const DocLnk & ); |
111 | void showEditTools(); | 111 | void showEditTools(); |
112 | 112 | ||
113 | void zoomIn(); | 113 | void zoomIn(); |
114 | void zoomOut(); | 114 | void zoomOut(); |
115 | void setBold(bool y); | 115 | void setBold(bool y); |
116 | void setItalic(bool y); | 116 | void setItalic(bool y); |
117 | void setWordWrap(bool y); | 117 | void setWordWrap(bool y); |
118 | void setSearchBar(bool); | 118 | void setSearchBar(bool); |
119 | 119 | ||
120 | private: | 120 | private: |
121 | void openDotFile(const QString &); | 121 | void openDotFile(const QString &); |
122 | void colorChanged( const QColor &c ); | 122 | void colorChanged( const QColor &c ); |
123 | void clear(); | 123 | void clear(); |
124 | void updateCaption( const QString &name=QString::null ); | 124 | void updateCaption( const QString &name=QString::null ); |
125 | void setFontSize(int sz, bool round_down_not_up); | 125 | void setFontSize(int sz, bool round_down_not_up); |
126 | private: | 126 | private: |
127 | // fileSaver *fileSaveDlg; | 127 | // fileSaver *fileSaveDlg; |
128 | // fileBrowser *browseForFiles; | 128 | // fileBrowser *browseForFiles; |
129 | bool fromSetDocument; | 129 | bool fromSetDocument; |
130 | QpeEditor* editor; | 130 | QpeEditor* editor; |
131 | QToolBar *menu, *editBar, *searchBar; | 131 | QToolBar *menu, *editBar, *searchBar; |
132 | QPopupMenu *advancedMenu; | 132 | QPopupMenu *advancedMenu; |
133 | QLineEdit *gotoEdit; | 133 | QLineEdit *gotoEdit; |
134 | QLineEdit *searchEdit; | 134 | QLineEdit *searchEdit; |
135 | DocLnk *doc; | 135 | DocLnk *doc; |
136 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; | 136 | bool fileIs, useAdvancedFeatures, promptExit, openDesktop, filePerms, useSearchBar, startWithNew; |
137 | bool bFromDocView; | 137 | bool bFromDocView; |
138 | int viewSelection; | 138 | int viewSelection; |
139 | QAction *zin, *zout; | 139 | QAction *zin, *zout; |
140 | QString currentFileName; | 140 | QString currentFileName; |
141 | }; | 141 | }; |
142 | 142 | ||
143 | #endif | 143 | #endif |