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,1587 +1,1588 @@ | |||
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 | { |
820 | getTe()->currentSession->setHistory(true); | 821 | getTe()->currentSession->setHistory(true); |
821 | } | 822 | } |
822 | } | 823 | } |
823 | 824 | ||
824 | delete d; | 825 | delete d; |
825 | } | 826 | } |
826 | 827 | ||
827 | 828 | ||
828 | void Konsole::cycleZoom() | 829 | void Konsole::cycleZoom() |
829 | { | 830 | { |
830 | TEWidget* te = getTe(); | 831 | TEWidget* te = getTe(); |
831 | QFont font = te->getVTFont(); | 832 | QFont font = te->getVTFont(); |
832 | int size = font.pointSize(); | 833 | int size = font.pointSize(); |
833 | changeFontSize(1); | 834 | changeFontSize(1); |
834 | font = te->getVTFont(); | 835 | font = te->getVTFont(); |
835 | if (font.pointSize() <= size) | 836 | if (font.pointSize() <= size) |
836 | { | 837 | { |
837 | do | 838 | do |
838 | { | 839 | { |
839 | font = te->getVTFont(); | 840 | font = te->getVTFont(); |
840 | size = font.pointSize(); | 841 | size = font.pointSize(); |
841 | changeFontSize(-1); | 842 | changeFontSize(-1); |
842 | font = te->getVTFont(); | 843 | font = te->getVTFont(); |
843 | } | 844 | } |
844 | while (font.pointSize() < size); | 845 | while (font.pointSize() < size); |
845 | } | 846 | } |
846 | } | 847 | } |
847 | 848 | ||
848 | void Konsole::changeFontSize(int delta) | 849 | void Konsole::changeFontSize(int delta) |
849 | { | 850 | { |
850 | // printf("delta font size %d\n", delta); | 851 | // printf("delta font size %d\n", delta); |
851 | TEWidget* te = getTe(); | 852 | TEWidget* te = getTe(); |
852 | QFont font = te->getVTFont(); | 853 | QFont font = te->getVTFont(); |
853 | int size = font.pointSize(); | 854 | int size = font.pointSize(); |
854 | int closest = delta > 0? 10000 : -10000; | 855 | int closest = delta > 0? 10000 : -10000; |
855 | int closest_font = -1; | 856 | int closest_font = -1; |
856 | for(uint i = 0; i < fonts.count(); i++) | 857 | for(uint i = 0; i < fonts.count(); i++) |
857 | { | 858 | { |
858 | if (fonts.at(i)->getFont() == font) | 859 | if (fonts.at(i)->getFont() == font) |
859 | { | 860 | { |
860 | if (delta > 0) | 861 | if (delta > 0) |
861 | { | 862 | { |
862 | if (i+1 < fonts.count() | 863 | if (i+1 < fonts.count() |
863 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 864 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
864 | { | 865 | { |
865 | setFont(i+1); | 866 | setFont(i+1); |
866 | printf("font %d\n", i+1); | 867 | printf("font %d\n", i+1); |
867 | return; | 868 | return; |
868 | } | 869 | } |
869 | } | 870 | } |
870 | else if (delta < 0) | 871 | else if (delta < 0) |
871 | { | 872 | { |
872 | if (i > 0 | 873 | if (i > 0 |
873 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 874 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
874 | { | 875 | { |
875 | setFont(i-1); | 876 | setFont(i-1); |
876 | printf("font %d\n", i-1); | 877 | printf("font %d\n", i-1); |
877 | return; | 878 | return; |
878 | } | 879 | } |
879 | } | 880 | } |
880 | } | 881 | } |
881 | int fsize = fonts.at(i)->getSize(); | 882 | int fsize = fonts.at(i)->getSize(); |
882 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 883 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
883 | if ((delta > 0 && fsize > size && fsize < closest) | 884 | if ((delta > 0 && fsize > size && fsize < closest) |
884 | || (delta < 0 && fsize < size && fsize > closest)) | 885 | || (delta < 0 && fsize < size && fsize > closest)) |
885 | { | 886 | { |
886 | closest = fsize; | 887 | closest = fsize; |
887 | closest_font = i; | 888 | closest_font = i; |
888 | } | 889 | } |
889 | } | 890 | } |
890 | if (closest_font >= 0) | 891 | if (closest_font >= 0) |
891 | { | 892 | { |
892 | printf("font closest %d (%d)\n", closest_font, closest); | 893 | printf("font closest %d (%d)\n", closest_font, closest); |
893 | setFont(closest_font); | 894 | setFont(closest_font); |
894 | } | 895 | } |
895 | } | 896 | } |
896 | 897 | ||
897 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 898 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
898 | { | 899 | { |
899 | for(uint i = 0; i < fonts.count(); i++) | 900 | for(uint i = 0; i < fonts.count(); i++) |
900 | { | 901 | { |
901 | if (fonts.at(i)->getName() == name | 902 | if (fonts.at(i)->getName() == name |
902 | && fonts.at(i)->getSize() == size) | 903 | && fonts.at(i)->getSize() == size) |
903 | { | 904 | { |
904 | return(i); | 905 | return(i); |
905 | } | 906 | } |
906 | } | 907 | } |
907 | if (exactMatch) | 908 | if (exactMatch) |
908 | { | 909 | { |
909 | return(-1); | 910 | return(-1); |
910 | } | 911 | } |
911 | for(uint i = 0; i < fonts.count(); i++) | 912 | for(uint i = 0; i < fonts.count(); i++) |
912 | { | 913 | { |
913 | if (fonts.at(i)->getSize() == size) | 914 | if (fonts.at(i)->getSize() == size) |
914 | { | 915 | { |
915 | return(i); | 916 | return(i); |
916 | } | 917 | } |
917 | } | 918 | } |
918 | return(-1); | 919 | return(-1); |
919 | } | 920 | } |
920 | 921 | ||
921 | void Konsole::setFont(int f) | 922 | void Konsole::setFont(int f) |
922 | { | 923 | { |
923 | VTFont* font = fonts.at(f); | 924 | VTFont* font = fonts.at(f); |
924 | if (font) | 925 | if (font) |
925 | { | 926 | { |
926 | TEWidget* te = getTe(); | 927 | TEWidget* te = getTe(); |
927 | if (te != 0) | 928 | if (te != 0) |
928 | { | 929 | { |
929 | te->setVTFont(font->getFont()); | 930 | te->setVTFont(font->getFont()); |
930 | } | 931 | } |
931 | cfont = f; | 932 | cfont = f; |
932 | 933 | ||
933 | int familyNum = font->getFamilyNum(); | 934 | int familyNum = font->getFamilyNum(); |
934 | int size = font->getSize(); | 935 | int size = font->getSize(); |
935 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 936 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
936 | fontList->count()); | 937 | fontList->count()); |
937 | for(int i = 0; i < (int)fontList->count(); i++) | 938 | for(int i = 0; i < (int)fontList->count(); i++) |
938 | { | 939 | { |
939 | fontList->setItemChecked(i + 1000, i == familyNum); | 940 | fontList->setItemChecked(i + 1000, i == familyNum); |
940 | } | 941 | } |
941 | for(int i = 0; i < (int)fonts.count(); i++) | 942 | for(int i = 0; i < (int)fonts.count(); i++) |
942 | { | 943 | { |
943 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 944 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
944 | && fonts.at(i)->getSize() == size); | 945 | && fonts.at(i)->getSize() == size); |
945 | } | 946 | } |
946 | Config cfg( "Konsole" ); | 947 | Config cfg( "Konsole" ); |
947 | cfg.setGroup("Font"); | 948 | cfg.setGroup("Font"); |
948 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 949 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
949 | if (tab->currentPageIndex() == 0) | 950 | if (tab->currentPageIndex() == 0) |
950 | { | 951 | { |
951 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 952 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
952 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 953 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
953 | } | 954 | } |
954 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 955 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
955 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 956 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
956 | } | 957 | } |
957 | } | 958 | } |
958 | 959 | ||
959 | #if 0 | 960 | #if 0 |
960 | void Konsole::fontChanged(int f) | 961 | void Konsole::fontChanged(int f) |
961 | { | 962 | { |
962 | VTFont* font = fonts.at(f); | 963 | VTFont* font = fonts.at(f); |
963 | if (font != 0) | 964 | if (font != 0) |
964 | { | 965 | { |
965 | for(uint i = 0; i < fonts.count(); i++) | 966 | for(uint i = 0; i < fonts.count(); i++) |
966 | { | 967 | { |
967 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 968 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
968 | } | 969 | } |
969 | 970 | ||
970 | cfont = f; | 971 | cfont = f; |
971 | 972 | ||
972 | TEWidget* te = getTe(); | 973 | TEWidget* te = getTe(); |
973 | if (te != 0) | 974 | if (te != 0) |
974 | { | 975 | { |
975 | te->setVTFont(font->getFont()); | 976 | te->setVTFont(font->getFont()); |
976 | } | 977 | } |
977 | } | 978 | } |
978 | } | 979 | } |
979 | #endif | 980 | #endif |
980 | 981 | ||
981 | 982 | ||
982 | void Konsole::enterCommand(int c) | 983 | void Konsole::enterCommand(int c) |
983 | { | 984 | { |
984 | TEWidget* te = getTe(); | 985 | TEWidget* te = getTe(); |
985 | if (te != 0) | 986 | if (te != 0) |
986 | { | 987 | { |
987 | if(!commonCombo->editable()) | 988 | if(!commonCombo->editable()) |
988 | { | 989 | { |
989 | QString text = commonCombo->text(c); //commonCmds[c]; | 990 | QString text = commonCombo->text(c); //commonCmds[c]; |
990 | te->emitText(text); | 991 | te->emitText(text); |
991 | } | 992 | } |
992 | else | 993 | else |
993 | { | 994 | { |
994 | changeCommand( commonCombo->text(c), c); | 995 | changeCommand( commonCombo->text(c), c); |
995 | } | 996 | } |
996 | } | 997 | } |
997 | } | 998 | } |
998 | 999 | ||
999 | void Konsole::hitEnter() | 1000 | void Konsole::hitEnter() |
1000 | { | 1001 | { |
1001 | TEWidget* te = getTe(); | 1002 | TEWidget* te = getTe(); |
1002 | if (te != 0) | 1003 | if (te != 0) |
1003 | { | 1004 | { |
1004 | te->emitText(QString("\r")); | 1005 | te->emitText(QString("\r")); |
1005 | } | 1006 | } |
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | void Konsole::hitSpace() | 1009 | void Konsole::hitSpace() |
1009 | { | 1010 | { |
1010 | TEWidget* te = getTe(); | 1011 | TEWidget* te = getTe(); |
1011 | if (te != 0) | 1012 | if (te != 0) |
1012 | { | 1013 | { |
1013 | te->emitText(QString(" ")); | 1014 | te->emitText(QString(" ")); |
1014 | } | 1015 | } |
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | void Konsole::hitTab() | 1018 | void Konsole::hitTab() |
1018 | { | 1019 | { |
1019 | TEWidget* te = getTe(); | 1020 | TEWidget* te = getTe(); |
1020 | if (te != 0) | 1021 | if (te != 0) |
1021 | { | 1022 | { |
1022 | te->emitText(QString("\t")); | 1023 | te->emitText(QString("\t")); |
1023 | } | 1024 | } |
1024 | } | 1025 | } |
1025 | 1026 | ||
1026 | void Konsole::hitPaste() | 1027 | void Konsole::hitPaste() |
1027 | { | 1028 | { |
1028 | TEWidget* te = getTe(); | 1029 | TEWidget* te = getTe(); |
1029 | if (te != 0) | 1030 | if (te != 0) |
1030 | { | 1031 | { |
1031 | te->pasteClipboard(); | 1032 | te->pasteClipboard(); |
1032 | } | 1033 | } |
1033 | } | 1034 | } |
1034 | 1035 | ||
1035 | void Konsole::hitUp() | 1036 | void Konsole::hitUp() |
1036 | { | 1037 | { |
1037 | TEWidget* te = getTe(); | 1038 | TEWidget* te = getTe(); |
1038 | if (te != 0) | 1039 | if (te != 0) |
1039 | { | 1040 | { |
1040 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1041 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1041 | QApplication::sendEvent( te, &ke ); | 1042 | QApplication::sendEvent( te, &ke ); |
1042 | } | 1043 | } |
1043 | } | 1044 | } |
1044 | 1045 | ||
1045 | void Konsole::hitDown() | 1046 | void Konsole::hitDown() |
1046 | { | 1047 | { |
1047 | TEWidget* te = getTe(); | 1048 | TEWidget* te = getTe(); |
1048 | if (te != 0) | 1049 | if (te != 0) |
1049 | { | 1050 | { |
1050 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1051 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1051 | QApplication::sendEvent( te, &ke ); | 1052 | QApplication::sendEvent( te, &ke ); |
1052 | } | 1053 | } |
1053 | } | 1054 | } |
1054 | 1055 | ||
1055 | /** | 1056 | /** |
1056 | This function calculates the size of the external widget | 1057 | This function calculates the size of the external widget |
1057 | needed for the internal widget to be | 1058 | needed for the internal widget to be |
1058 | */ | 1059 | */ |
1059 | QSize Konsole::calcSize(int columns, int lines) | 1060 | QSize Konsole::calcSize(int columns, int lines) |
1060 | { | 1061 | { |
1061 | TEWidget* te = getTe(); | 1062 | TEWidget* te = getTe(); |
1062 | if (te != 0) | 1063 | if (te != 0) |
1063 | { | 1064 | { |
1064 | QSize size = te->calcSize(columns, lines); | 1065 | QSize size = te->calcSize(columns, lines); |
1065 | return size; | 1066 | return size; |
1066 | } | 1067 | } |
1067 | else | 1068 | else |
1068 | { | 1069 | { |
1069 | QSize size; | 1070 | QSize size; |
1070 | return size; | 1071 | return size; |
1071 | } | 1072 | } |
1072 | } | 1073 | } |
1073 | 1074 | ||
1074 | /** | 1075 | /** |
1075 | sets application window to a size based on columns X lines of the te | 1076 | sets application window to a size based on columns X lines of the te |
1076 | guest widget. Call with (0,0) for setting default size. | 1077 | guest widget. Call with (0,0) for setting default size. |
1077 | */ | 1078 | */ |
1078 | 1079 | ||
1079 | void Konsole::setColLin(int columns, int lines) | 1080 | void Konsole::setColLin(int columns, int lines) |
1080 | { | 1081 | { |
1081 | qDebug("konsole::setColLin:: Columns %d", columns); | 1082 | qDebug("konsole::setColLin:: Columns %d", columns); |
1082 | 1083 | ||
1083 | if ((columns==0) || (lines==0)) | 1084 | if ((columns==0) || (lines==0)) |
1084 | { | 1085 | { |
1085 | if (defaultSize.isEmpty()) // not in config file : set default value | 1086 | if (defaultSize.isEmpty()) // not in config file : set default value |
1086 | { | 1087 | { |
1087 | defaultSize = calcSize(80,24); | 1088 | defaultSize = calcSize(80,24); |
1088 | // notifySize(24,80); // set menu items (strange arg order !) | 1089 | // notifySize(24,80); // set menu items (strange arg order !) |
1089 | } | 1090 | } |
1090 | resize(defaultSize); | 1091 | resize(defaultSize); |
1091 | } | 1092 | } |
1092 | else | 1093 | else |
1093 | { | 1094 | { |
1094 | resize(calcSize(columns, lines)); | 1095 | resize(calcSize(columns, lines)); |
1095 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1096 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1096 | } | 1097 | } |
1097 | } | 1098 | } |
1098 | 1099 | ||
1099 | /* | 1100 | /* |
1100 | void Konsole::setFont(int fontno) | 1101 | void Konsole::setFont(int fontno) |
1101 | { | 1102 | { |
1102 | QFont f; | 1103 | QFont f; |
1103 | if (fontno == 0) | 1104 | if (fontno == 0) |
1104 | f = defaultFont = QFont( "Helvetica", 12 ); | 1105 | f = defaultFont = QFont( "Helvetica", 12 ); |
1105 | else | 1106 | else |
1106 | if (fonts[fontno][0] == '-') | 1107 | if (fonts[fontno][0] == '-') |
1107 | f.setRawName( fonts[fontno] ); | 1108 | f.setRawName( fonts[fontno] ); |
1108 | else | 1109 | else |
1109 | { | 1110 | { |
1110 | f.setFamily(fonts[fontno]); | 1111 | f.setFamily(fonts[fontno]); |
1111 | f.setRawMode( TRUE ); | 1112 | f.setRawMode( TRUE ); |
1112 | } | 1113 | } |
1113 | if ( !f.exactMatch() && fontno != 0) | 1114 | if ( !f.exactMatch() && fontno != 0) |
1114 | { | 1115 | { |
1115 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1116 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1116 | QMessageBox(this, msg); | 1117 | QMessageBox(this, msg); |
1117 | return; | 1118 | return; |
1118 | } | 1119 | } |
1119 | if (se) se->setFontNo(fontno); | 1120 | if (se) se->setFontNo(fontno); |
1120 | te->setVTFont(f); | 1121 | te->setVTFont(f); |
1121 | n_font = fontno; | 1122 | n_font = fontno; |
1122 | } | 1123 | } |
1123 | */ | 1124 | */ |
1124 | 1125 | ||
1125 | // --| color selection |------------------------------------------------------- | 1126 | // --| color selection |------------------------------------------------------- |
1126 | 1127 | ||
1127 | void Konsole::changeColumns(int /*columns*/) | 1128 | void Konsole::changeColumns(int /*columns*/) |
1128 | { //FIXME this seems to cause silliness when reset command is executed | 1129 | { //FIXME this seems to cause silliness when reset command is executed |
1129 | // qDebug("change columns"); | 1130 | // qDebug("change columns"); |
1130 | // TEWidget* te = getTe(); | 1131 | // TEWidget* te = getTe(); |
1131 | // if (te != 0) { | 1132 | // if (te != 0) { |
1132 | // setColLin(columns,te->Lines()); | 1133 | // setColLin(columns,te->Lines()); |
1133 | // te->update(); | 1134 | // te->update(); |
1134 | // } | 1135 | // } |
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | //FIXME: If a child dies during session swap, | 1138 | //FIXME: If a child dies during session swap, |
1138 | // this routine might be called before | 1139 | // this routine might be called before |
1139 | // session swap is completed. | 1140 | // session swap is completed. |
1140 | 1141 | ||
1141 | void Konsole::doneSession(TEWidget* te, int ) | 1142 | void Konsole::doneSession(TEWidget* te, int ) |
1142 | { | 1143 | { |
1143 | // TEWidget *te = NULL; | 1144 | // TEWidget *te = NULL; |
1144 | // if (sess->currentSession == tab->currentPage()) { | 1145 | // if (sess->currentSession == tab->currentPage()) { |
1145 | // printf("done current session\n"); | 1146 | // printf("done current session\n"); |
1146 | // te = getTe(); | 1147 | // te = getTe(); |
1147 | // } else { | 1148 | // } else { |
1148 | // int currentPage = tab->currentPageIndex(); | 1149 | // int currentPage = tab->currentPageIndex(); |
1149 | // printf("done not current session\n"); | 1150 | // printf("done not current session\n"); |
1150 | // for(int i = 0; i < nsessions; i++) { | 1151 | // for(int i = 0; i < nsessions; i++) { |
1151 | // tab->setCurrentPage(i); | 1152 | // tab->setCurrentPage(i); |
1152 | // printf("find session %d tab page %x session %x\n", | 1153 | // printf("find session %d tab page %x session %x\n", |
1153 | // i, tab->currentPage(), sess->currentSession); | 1154 | // i, tab->currentPage(), sess->currentSession); |
1154 | // if (tab->currentPage() == sess->currentSession) { | 1155 | // if (tab->currentPage() == sess->currentSession) { |
1155 | // printf("found session %d\n", i); | 1156 | // printf("found session %d\n", i); |
1156 | // te = tab->currentPage(); | 1157 | // te = tab->currentPage(); |
1157 | // break; | 1158 | // break; |
1158 | // } | 1159 | // } |
1159 | // } | 1160 | // } |
1160 | // tab->setCurrentPage(currentPage); | 1161 | // tab->setCurrentPage(currentPage); |
1161 | // } | 1162 | // } |
1162 | if (te != 0) | 1163 | if (te != 0) |
1163 | { | 1164 | { |
1164 | te->currentSession->setConnect(FALSE); | 1165 | te->currentSession->setConnect(FALSE); |
1165 | tab->removeTab(te); | 1166 | tab->removeTab(te); |
1166 | delete te->currentSession; | 1167 | delete te->currentSession; |
1167 | delete te; | 1168 | delete te; |
1168 | sessionList->removeItem(nsessions); | 1169 | sessionList->removeItem(nsessions); |
1169 | nsessions--; | 1170 | nsessions--; |
1170 | } | 1171 | } |
1171 | if (nsessions == 0) | 1172 | if (nsessions == 0) |
1172 | { | 1173 | { |
1173 | close(); | 1174 | close(); |
1174 | } | 1175 | } |
1175 | } | 1176 | } |
1176 | 1177 | ||
1177 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) | 1178 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) |
1178 | { | 1179 | { |
1179 | if (te == getTe()) | 1180 | if (te == getTe()) |
1180 | { | 1181 | { |
1181 | setCaption( newTitle + " - " + tr( "Konsole " ) ); | 1182 | setCaption( newTitle + " - " + tr( "Konsole " ) ); |
1182 | } | 1183 | } |
1183 | } | 1184 | } |
1184 | 1185 | ||
1185 | 1186 | ||
1186 | void Konsole::newSession() | 1187 | void Konsole::newSession() |
1187 | { | 1188 | { |
1188 | if(nsessions < 15) | 1189 | if(nsessions < 15) |
1189 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 1190 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
1190 | TEWidget* te = new TEWidget(tab); | 1191 | TEWidget* te = new TEWidget(tab); |
1191 | Config cfg( "Konsole" ); | 1192 | Config cfg( "Konsole" ); |
1192 | cfg.setGroup("Menubar"); | 1193 | cfg.setGroup("Menubar"); |
1193 | 1194 | ||
1194 | // FIXME use more defaults from config file | 1195 | // FIXME use more defaults from config file |
1195 | te->useBeep=cfg.readBoolEntry("useBeep",0); | 1196 | te->useBeep=cfg.readBoolEntry("useBeep",0); |
1196 | 1197 | ||
1197 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1198 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
1198 | 1199 | ||
1199 | cfg.setGroup("Font"); | 1200 | cfg.setGroup("Font"); |
1200 | QString sn = "Session" + QString::number(nsessions+1); | 1201 | QString sn = "Session" + QString::number(nsessions+1); |
1201 | printf("read font session %s\n", sn.latin1()); | 1202 | printf("read font session %s\n", sn.latin1()); |
1202 | QString fontName = cfg.readEntry("FontName"+sn, | 1203 | QString fontName = cfg.readEntry("FontName"+sn, |
1203 | cfg.readEntry("FontName", | 1204 | cfg.readEntry("FontName", |
1204 | fonts.at(cfont)->getFamily())); | 1205 | fonts.at(cfont)->getFamily())); |
1205 | int fontSize = cfg.readNumEntry("FontSize"+sn, | 1206 | int fontSize = cfg.readNumEntry("FontSize"+sn, |
1206 | cfg.readNumEntry("FontSize", | 1207 | cfg.readNumEntry("FontSize", |
1207 | fonts.at(cfont)->getSize())); | 1208 | fonts.at(cfont)->getSize())); |
1208 | cfont = findFont(fontName, fontSize, false); | 1209 | cfont = findFont(fontName, fontSize, false); |
1209 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | 1210 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); |
1210 | if (cfont < 0) | 1211 | if (cfont < 0) |
1211 | cfont = 0; | 1212 | cfont = 0; |
1212 | te->setVTFont(fonts.at(cfont)->getFont()); | 1213 | te->setVTFont(fonts.at(cfont)->getFont()); |
1213 | 1214 | ||
1214 | tab->addTab(te); | 1215 | tab->addTab(te); |
1215 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1216 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
1216 | te->currentSession = se; | 1217 | te->currentSession = se; |
1217 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); | 1218 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1218 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, | 1219 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, |
1219 | SLOT(changeTitle(TEWidget*,const QString&)) ); | 1220 | SLOT(changeTitle(TEWidget*,const QString&)) ); |
1220 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | 1221 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); |
1221 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | 1222 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); |
1222 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | 1223 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); |
1223 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | 1224 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); |
1224 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | 1225 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); |
1225 | se->run(); | 1226 | se->run(); |
1226 | se->setConnect(TRUE); | 1227 | se->setConnect(TRUE); |
1227 | se->setHistory(b_scroll); | 1228 | se->setHistory(b_scroll); |
1228 | nsessions++; | 1229 | nsessions++; |
1229 | sessionList->insertItem(QString::number(nsessions), nsessions); | 1230 | sessionList->insertItem(QString::number(nsessions), nsessions); |
1230 | sessionListSelected(nsessions); | 1231 | sessionListSelected(nsessions); |
1231 | doWrap(); | 1232 | doWrap(); |
1232 | setColor(nsessions-1); | 1233 | setColor(nsessions-1); |
1233 | } | 1234 | } |
1234 | } | 1235 | } |
1235 | 1236 | ||
1236 | TEWidget* Konsole::getTe() | 1237 | TEWidget* Konsole::getTe() |
1237 | { | 1238 | { |
1238 | if (nsessions) | 1239 | if (nsessions) |
1239 | { | 1240 | { |
1240 | return (TEWidget *) tab->currentPage(); | 1241 | return (TEWidget *) tab->currentPage(); |
1241 | } | 1242 | } |
1242 | else | 1243 | else |
1243 | { | 1244 | { |
1244 | return 0; | 1245 | return 0; |
1245 | } | 1246 | } |
1246 | } | 1247 | } |
1247 | 1248 | ||
1248 | void Konsole::sessionListSelected(int id) | 1249 | void Konsole::sessionListSelected(int id) |
1249 | { | 1250 | { |
1250 | if (id < 0) | 1251 | if (id < 0) |
1251 | { | 1252 | { |
1252 | return; | 1253 | return; |
1253 | } | 1254 | } |
1254 | QString selected = sessionList->text(id); | 1255 | QString selected = sessionList->text(id); |
1255 | EKNumTabBar *tabBar = tab->getTabBar(); | 1256 | EKNumTabBar *tabBar = tab->getTabBar(); |
1256 | 1257 | ||
1257 | int n = 0; | 1258 | int n = 0; |
1258 | for(int i = 0; n < tabBar->count(); i++) | 1259 | for(int i = 0; n < tabBar->count(); i++) |
1259 | { | 1260 | { |
1260 | if (tabBar->tab(i)) | 1261 | if (tabBar->tab(i)) |
1261 | { | 1262 | { |
1262 | // printf("selected = %s tab %d = %s\n", selected.latin1(), | 1263 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
1263 | // i, tabBar->tab(i)->text().latin1()); | 1264 | // i, tabBar->tab(i)->text().latin1()); |
1264 | if (tabBar->tab(i)->text() == selected) | 1265 | if (tabBar->tab(i)->text() == selected) |
1265 | { | 1266 | { |
1266 | tab->setCurrentPage(i); | 1267 | tab->setCurrentPage(i); |
1267 | break; | 1268 | break; |
1268 | } | 1269 | } |
1269 | n++; | 1270 | n++; |
1270 | } | 1271 | } |
1271 | } | 1272 | } |
1272 | } | 1273 | } |
1273 | 1274 | ||
1274 | 1275 | ||
1275 | void Konsole::changeSession(int delta) | 1276 | void Konsole::changeSession(int delta) |
1276 | { | 1277 | { |
1277 | printf("delta session %d\n", delta); | 1278 | printf("delta session %d\n", delta); |
1278 | QTabBar *tabBar = tab->getTabBar(); | 1279 | QTabBar *tabBar = tab->getTabBar(); |
1279 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | 1280 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; |
1280 | i += delta; | 1281 | i += delta; |
1281 | if (i < 0) | 1282 | if (i < 0) |
1282 | i += tabBar->count(); | 1283 | i += tabBar->count(); |
1283 | if (i >= tabBar->count()) | 1284 | if (i >= tabBar->count()) |
1284 | i -= tabBar->count(); | 1285 | i -= tabBar->count(); |
1285 | 1286 | ||
1286 | QString selected = QString::number(i+1); | 1287 | QString selected = QString::number(i+1); |
1287 | int n = 0; | 1288 | int n = 0; |
1288 | for(int i = 0; n < tabBar->count(); i++) | 1289 | for(int i = 0; n < tabBar->count(); i++) |
1289 | { | 1290 | { |
1290 | if (tabBar->tab(i)) | 1291 | if (tabBar->tab(i)) |
1291 | { | 1292 | { |
1292 | printf("selected = %s tab %d = %s\n", selected.latin1(), | 1293 | printf("selected = %s tab %d = %s\n", selected.latin1(), |
1293 | i, tabBar->tab(i)->text().latin1()); | 1294 | i, tabBar->tab(i)->text().latin1()); |
1294 | if (tabBar->tab(i)->text() == selected) | 1295 | if (tabBar->tab(i)->text() == selected) |
1295 | { | 1296 | { |
1296 | tab->setCurrentPage(i); | 1297 | tab->setCurrentPage(i); |
1297 | break; | 1298 | break; |
1298 | } | 1299 | } |
1299 | n++; | 1300 | n++; |
1300 | } | 1301 | } |
1301 | } | 1302 | } |
1302 | } | 1303 | } |
1303 | 1304 | ||
1304 | void Konsole::switchSession(QWidget* w) | 1305 | void Konsole::switchSession(QWidget* w) |
1305 | { | 1306 | { |
1306 | TEWidget* te = (TEWidget *) w; | 1307 | TEWidget* te = (TEWidget *) w; |
1307 | QFont teFnt = te->getVTFont(); | 1308 | QFont teFnt = te->getVTFont(); |
1308 | int familyNum = -1; | 1309 | int familyNum = -1; |
1309 | 1310 | ||
1310 | for(uint i = 0; i < fonts.count(); i++) | 1311 | for(uint i = 0; i < fonts.count(); i++) |
1311 | { | 1312 | { |
1312 | VTFont *fnt = fonts.at(i); | 1313 | VTFont *fnt = fonts.at(i); |
1313 | bool cf = fnt->getFont() == teFnt; | 1314 | bool cf = fnt->getFont() == teFnt; |
1314 | fontList->setItemChecked(i, cf); | 1315 | fontList->setItemChecked(i, cf); |
1315 | if (cf) | 1316 | if (cf) |
1316 | { | 1317 | { |
1317 | cfont = i; | 1318 | cfont = i; |
1318 | familyNum = fnt->getFamilyNum(); | 1319 | familyNum = fnt->getFamilyNum(); |
1319 | } | 1320 | } |
1320 | } | 1321 | } |
1321 | for(int i = 0; i < (int)fontList->count(); i++) | 1322 | for(int i = 0; i < (int)fontList->count(); i++) |
1322 | { | 1323 | { |
1323 | fontList->setItemChecked(i + 1000, i == familyNum); | 1324 | fontList->setItemChecked(i + 1000, i == familyNum); |
1324 | } | 1325 | } |
1325 | if (! te->currentSession->Title().isEmpty() ) | 1326 | if (! te->currentSession->Title().isEmpty() ) |
1326 | { | 1327 | { |
1327 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); | 1328 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); |
1328 | } | 1329 | } |
1329 | else | 1330 | else |
1330 | { | 1331 | { |
1331 | setCaption( tr( "Konsole" ) ); | 1332 | setCaption( tr( "Konsole" ) ); |
1332 | } | 1333 | } |
1333 | // colorMenuSelected(te->color_menu_item); | 1334 | // colorMenuSelected(te->color_menu_item); |
1334 | } | 1335 | } |
1335 | 1336 | ||
1336 | 1337 | ||
1337 | void Konsole::toggleFullScreen() | 1338 | void Konsole::toggleFullScreen() |
1338 | { | 1339 | { |
1339 | setFullScreen(! fullscreen); | 1340 | setFullScreen(! fullscreen); |
1340 | } | 1341 | } |
1341 | 1342 | ||
1342 | void Konsole::setFullScreen ( bool b ) | 1343 | void Konsole::setFullScreen ( bool b ) |
1343 | { | 1344 | { |
1344 | static QSize normalsize; | 1345 | static QSize normalsize; |
1345 | static bool listHidden; | 1346 | static bool listHidden; |
1346 | 1347 | ||
1347 | if (b == fullscreen) | 1348 | if (b == fullscreen) |
1348 | { | 1349 | { |
1349 | return; | 1350 | return; |
1350 | } | 1351 | } |
1351 | 1352 | ||
1352 | fullscreen = b; | 1353 | fullscreen = b; |
1353 | 1354 | ||
1354 | if ( b ) | 1355 | if ( b ) |
1355 | { | 1356 | { |
1356 | if ( !normalsize. isValid ( )) | 1357 | if ( !normalsize. isValid ( )) |
1357 | { | 1358 | { |
1358 | normalsize = size ( ); | 1359 | normalsize = size ( ); |
1359 | } | 1360 | } |
1360 | 1361 | ||
1361 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 1362 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
1362 | showNormal ( ); | 1363 | showNormal ( ); |
1363 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 1364 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
1364 | QPoint ( 0, 0 )); | 1365 | QPoint ( 0, 0 )); |
1365 | showFullScreen ( ); | 1366 | showFullScreen ( ); |
1366 | 1367 | ||
1367 | menuToolBar->hide(); | 1368 | menuToolBar->hide(); |
1368 | toolBar->hide(); | 1369 | toolBar->hide(); |
1369 | listHidden = secondToolBar->isHidden(); | 1370 | listHidden = secondToolBar->isHidden(); |
1370 | secondToolBar->hide(); | 1371 | secondToolBar->hide(); |
1371 | // commonCombo->hide(); | 1372 | // commonCombo->hide(); |
1372 | tab->getTabBar()->hide(); | 1373 | tab->getTabBar()->hide(); |
1373 | tab->setMargin(tab->margin()); | 1374 | tab->setMargin(tab->margin()); |
1374 | 1375 | ||
1375 | if (show_fullscreen_msg) | 1376 | if (show_fullscreen_msg) |
1376 | { | 1377 | { |
1377 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | 1378 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, |
1378 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | 1379 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); |
1379 | fullscreen_msg->show(); | 1380 | fullscreen_msg->show(); |
1380 | fullscreen_timer->start(3000, true); | 1381 | fullscreen_timer->start(3000, true); |
1381 | show_fullscreen_msg = false; | 1382 | show_fullscreen_msg = false; |
1382 | } | 1383 | } |
1383 | } | 1384 | } |
1384 | else | 1385 | else |
1385 | { | 1386 | { |
1386 | showNormal ( ); | 1387 | showNormal ( ); |
1387 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); | 1388 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); |
1388 | resize ( normalsize ); | 1389 | resize ( normalsize ); |
1389 | showMaximized ( ); | 1390 | showMaximized ( ); |
1390 | normalsize = QSize ( ); | 1391 | normalsize = QSize ( ); |
1391 | 1392 | ||
1392 | menuToolBar->show(); | 1393 | menuToolBar->show(); |
1393 | toolBar->show(); | 1394 | toolBar->show(); |
1394 | if(! listHidden) | 1395 | if(! listHidden) |
1395 | { | 1396 | { |
1396 | secondToolBar->show(); | 1397 | secondToolBar->show(); |
1397 | } | 1398 | } |
1398 | // commonCombo->show(); | 1399 | // commonCombo->show(); |
1399 | menuToolBar->show(); | 1400 | menuToolBar->show(); |
1400 | if (tabPos != tm_hidden) | 1401 | if (tabPos != tm_hidden) |
1401 | { | 1402 | { |
1402 | tab->getTabBar()->show(); | 1403 | tab->getTabBar()->show(); |
1403 | } | 1404 | } |
1404 | } | 1405 | } |
1405 | tab->setMargin(tab->margin()); // cause setup to run | 1406 | tab->setMargin(tab->margin()); // cause setup to run |
1406 | } | 1407 | } |
1407 | 1408 | ||
1408 | 1409 | ||
1409 | void Konsole::fullscreenTimeout() | 1410 | void Konsole::fullscreenTimeout() |
1410 | { | 1411 | { |
1411 | fullscreen_msg->hide(); | 1412 | fullscreen_msg->hide(); |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | void Konsole::colorMenuIsSelected(int iD) | 1415 | void Konsole::colorMenuIsSelected(int iD) |
1415 | { | 1416 | { |
1416 | fromMenu = TRUE; | 1417 | fromMenu = TRUE; |
1417 | colorMenuSelected(iD); | 1418 | colorMenuSelected(iD); |
1418 | } | 1419 | } |
1419 | 1420 | ||
1420 | /// ------------------------------- some new stuff by L.J. Potter | 1421 | /// ------------------------------- some new stuff by L.J. Potter |
1421 | 1422 | ||
1422 | 1423 | ||
1423 | void Konsole::colorMenuSelected(int iD) | 1424 | void Konsole::colorMenuSelected(int iD) |
1424 | { | 1425 | { |
1425 | // this is NOT pretty, elegant or anything else besides functional | 1426 | // this is NOT pretty, elegant or anything else besides functional |
1426 | // QString temp; | 1427 | // QString temp; |
1427 | // qDebug( temp.sprintf("colormenu %d", iD)); | 1428 | // qDebug( temp.sprintf("colormenu %d", iD)); |
1428 | 1429 | ||
1429 | TEWidget* te = getTe(); | 1430 | TEWidget* te = getTe(); |
1430 | Config cfg( "Konsole" ); | 1431 | Config cfg( "Konsole" ); |
1431 | cfg.setGroup("Colors"); | 1432 | cfg.setGroup("Colors"); |
1432 | 1433 | ||
1433 | ColorEntry m_table[TABLE_COLORS]; | 1434 | ColorEntry m_table[TABLE_COLORS]; |
1434 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1435 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1435 | 1436 | ||
1436 | int i; | 1437 | int i; |
1437 | 1438 | ||
1438 | // te->color_menu_item = iD; | 1439 | // te->color_menu_item = iD; |
1439 | 1440 | ||
1440 | colorMenu->setItemChecked(cm_ab,FALSE); | 1441 | colorMenu->setItemChecked(cm_ab,FALSE); |
1441 | colorMenu->setItemChecked(cm_bb,FALSE); | 1442 | colorMenu->setItemChecked(cm_bb,FALSE); |
1442 | colorMenu->setItemChecked(cm_wc,FALSE); | 1443 | colorMenu->setItemChecked(cm_wc,FALSE); |
1443 | colorMenu->setItemChecked(cm_cw,FALSE); | 1444 | colorMenu->setItemChecked(cm_cw,FALSE); |
1444 | colorMenu->setItemChecked(cm_mb,FALSE); | 1445 | colorMenu->setItemChecked(cm_mb,FALSE); |
1445 | colorMenu->setItemChecked(cm_bm,FALSE); | 1446 | colorMenu->setItemChecked(cm_bm,FALSE); |
1446 | colorMenu->setItemChecked(cm_gy,FALSE); | 1447 | colorMenu->setItemChecked(cm_gy,FALSE); |
1447 | colorMenu->setItemChecked(cm_rb,FALSE); | 1448 | colorMenu->setItemChecked(cm_rb,FALSE); |
1448 | colorMenu->setItemChecked(cm_br,FALSE); | 1449 | colorMenu->setItemChecked(cm_br,FALSE); |
1449 | colorMenu->setItemChecked(cm_wb,FALSE); | 1450 | colorMenu->setItemChecked(cm_wb,FALSE); |
1450 | colorMenu->setItemChecked(cm_bw,FALSE); | 1451 | colorMenu->setItemChecked(cm_bw,FALSE); |
1451 | colorMenu->setItemChecked(cm_gb,FALSE); | 1452 | colorMenu->setItemChecked(cm_gb,FALSE); |
1452 | 1453 | ||
1453 | if(iD==cm_default) | 1454 | if(iD==cm_default) |
1454 | { // default default | 1455 | { // default default |
1455 | printf("default colors\n"); | 1456 | printf("default colors\n"); |
1456 | for (i = 0; i < TABLE_COLORS; i++) | 1457 | for (i = 0; i < TABLE_COLORS; i++) |
1457 | { | 1458 | { |
1458 | m_table[i].color = defaultCt[i].color; | 1459 | m_table[i].color = defaultCt[i].color; |
1459 | if(i==1 || i == 11) | 1460 | if(i==1 || i == 11) |
1460 | m_table[i].transparent=1; | 1461 | m_table[i].transparent=1; |
1461 | colorMenu->setItemChecked(cm_default,TRUE); | 1462 | colorMenu->setItemChecked(cm_default,TRUE); |
1462 | } | 1463 | } |
1463 | te->setColorTable(m_table); | 1464 | te->setColorTable(m_table); |
1464 | } | 1465 | } |
1465 | if(iD==cm_gb) | 1466 | if(iD==cm_gb) |
1466 | { // green black | 1467 | { // green black |
1467 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | 1468 | foreground.setRgb(100,255,100); // (0x18,255,0x18); |
1468 | background.setRgb(0x00,0x00,0x00); | 1469 | background.setRgb(0x00,0x00,0x00); |
1469 | colorMenu->setItemChecked(cm_gb,TRUE); | 1470 | colorMenu->setItemChecked(cm_gb,TRUE); |
1470 | } | 1471 | } |
1471 | if(iD==cm_bw) | 1472 | if(iD==cm_bw) |
1472 | { // black white | 1473 | { // black white |
1473 | foreground.setRgb(0x00,0x00,0x00); | 1474 | foreground.setRgb(0x00,0x00,0x00); |
1474 | background.setRgb(0xFF,0xFF,0xFF); | 1475 | background.setRgb(0xFF,0xFF,0xFF); |
1475 | colorMenu->setItemChecked(cm_bw,TRUE); | 1476 | colorMenu->setItemChecked(cm_bw,TRUE); |
1476 | } | 1477 | } |
1477 | if(iD==cm_wb) | 1478 | if(iD==cm_wb) |
1478 | { // white black | 1479 | { // white black |
1479 | foreground.setRgb(0xFF,0xFF,0xFF); | 1480 | foreground.setRgb(0xFF,0xFF,0xFF); |
1480 | background.setRgb(0x00,0x00,0x00); | 1481 | background.setRgb(0x00,0x00,0x00); |
1481 | colorMenu->setItemChecked(cm_wb,TRUE); | 1482 | colorMenu->setItemChecked(cm_wb,TRUE); |
1482 | } | 1483 | } |
1483 | if(iD==cm_br) | 1484 | if(iD==cm_br) |
1484 | {// Black, Red | 1485 | {// Black, Red |
1485 | foreground.setRgb(0x00,0x00,0x00); | 1486 | foreground.setRgb(0x00,0x00,0x00); |
1486 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | 1487 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); |
1487 | colorMenu->setItemChecked(cm_br,TRUE); | 1488 | colorMenu->setItemChecked(cm_br,TRUE); |
1488 | } | 1489 | } |
1489 | if(iD==cm_rb) | 1490 | if(iD==cm_rb) |
1490 | {// Red, Black | 1491 | {// Red, Black |
1491 | foreground.setRgb(255,85,85); | 1492 | foreground.setRgb(255,85,85); |
1492 | background.setRgb(0x00,0x00,0x00); | 1493 | background.setRgb(0x00,0x00,0x00); |
1493 | colorMenu->setItemChecked(cm_rb,TRUE); | 1494 | colorMenu->setItemChecked(cm_rb,TRUE); |
1494 | } | 1495 | } |
1495 | if(iD==cm_gy) | 1496 | if(iD==cm_gy) |
1496 | {// Green, Yellow - is ugly | 1497 | {// Green, Yellow - is ugly |
1497 | // foreground.setRgb(0x18,0xB2,0x18); | 1498 | // foreground.setRgb(0x18,0xB2,0x18); |
1498 | foreground.setRgb(15,115,0); | 1499 | foreground.setRgb(15,115,0); |
1499 | // background.setRgb(0xB2,0x68,0x18); | 1500 | // background.setRgb(0xB2,0x68,0x18); |
1500 | background.setRgb(255,255,0); | 1501 | background.setRgb(255,255,0); |
1501 | colorMenu->setItemChecked(cm_gy,TRUE); | 1502 | colorMenu->setItemChecked(cm_gy,TRUE); |
1502 | } | 1503 | } |
1503 | if(iD==cm_bm) | 1504 | if(iD==cm_bm) |
1504 | {// Blue, Magenta | 1505 | {// Blue, Magenta |
1505 | foreground.setRgb(3,24,132); | 1506 | foreground.setRgb(3,24,132); |
1506 | background.setRgb(225,2,255); | 1507 | background.setRgb(225,2,255); |
1507 | colorMenu->setItemChecked(cm_bm,TRUE); | 1508 | colorMenu->setItemChecked(cm_bm,TRUE); |
1508 | } | 1509 | } |
1509 | if(iD==cm_mb) | 1510 | if(iD==cm_mb) |
1510 | {// Magenta, Blue | 1511 | {// Magenta, Blue |
1511 | foreground.setRgb(225,2,255); | 1512 | foreground.setRgb(225,2,255); |
1512 | background.setRgb(3,24,132); | 1513 | background.setRgb(3,24,132); |
1513 | colorMenu->setItemChecked(cm_mb,TRUE); | 1514 | colorMenu->setItemChecked(cm_mb,TRUE); |
1514 | } | 1515 | } |
1515 | if(iD==cm_cw) | 1516 | if(iD==cm_cw) |
1516 | {// Cyan, White | 1517 | {// Cyan, White |
1517 | foreground.setRgb(8,91,129); | 1518 | foreground.setRgb(8,91,129); |
1518 | background.setRgb(0xFF,0xFF,0xFF); | 1519 | background.setRgb(0xFF,0xFF,0xFF); |
1519 | colorMenu->setItemChecked(cm_cw,TRUE); | 1520 | colorMenu->setItemChecked(cm_cw,TRUE); |
1520 | } | 1521 | } |
1521 | if(iD==cm_wc) | 1522 | if(iD==cm_wc) |
1522 | {// White, Cyan | 1523 | {// White, Cyan |
1523 | background.setRgb(8,91,129); | 1524 | background.setRgb(8,91,129); |
1524 | foreground.setRgb(0xFF,0xFF,0xFF); | 1525 | foreground.setRgb(0xFF,0xFF,0xFF); |
1525 | colorMenu->setItemChecked(cm_wc,TRUE); | 1526 | colorMenu->setItemChecked(cm_wc,TRUE); |
1526 | } | 1527 | } |
1527 | if(iD==cm_bb) | 1528 | if(iD==cm_bb) |
1528 | {// Black, Blue | 1529 | {// Black, Blue |
1529 | background.setRgb(0x00,0x00,0x00); | 1530 | background.setRgb(0x00,0x00,0x00); |
1530 | foreground.setRgb(127,147,225); | 1531 | foreground.setRgb(127,147,225); |
1531 | colorMenu->setItemChecked(cm_bb,TRUE); | 1532 | colorMenu->setItemChecked(cm_bb,TRUE); |
1532 | } | 1533 | } |
1533 | if(iD==cm_ab) | 1534 | if(iD==cm_ab) |
1534 | {// Black, Gold | 1535 | {// Black, Gold |
1535 | background.setRgb(0x00,0x00,0x00); | 1536 | background.setRgb(0x00,0x00,0x00); |
1536 | foreground.setRgb(255,215,105); | 1537 | foreground.setRgb(255,215,105); |
1537 | colorMenu->setItemChecked(cm_ab,TRUE); | 1538 | colorMenu->setItemChecked(cm_ab,TRUE); |
1538 | } | 1539 | } |
1539 | #ifdef QT_QWS_OPIE | 1540 | #ifdef QT_QWS_OPIE |
1540 | if(iD==-19) | 1541 | if(iD==-19) |
1541 | { | 1542 | { |
1542 | // Custom | 1543 | // Custom |
1543 | qDebug("do custom"); | 1544 | qDebug("do custom"); |
1544 | if(fromMenu) | 1545 | if(fromMenu) |
1545 | { | 1546 | { |
1546 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); | 1547 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); |
1547 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1548 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
1548 | SLOT(changeForegroundColor(const QColor&))); | 1549 | SLOT(changeForegroundColor(const QColor&))); |
1549 | penColorPopupMenu->exec(); | 1550 | penColorPopupMenu->exec(); |
1550 | } | 1551 | } |
1551 | if(!fromMenu) | 1552 | if(!fromMenu) |
1552 | { | 1553 | { |
1553 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 1554 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
1554 | background.setNamedColor(cfg.readEntry("background","")); | 1555 | background.setNamedColor(cfg.readEntry("background","")); |
1555 | } | 1556 | } |
1556 | fromMenu=FALSE; | 1557 | fromMenu=FALSE; |
1557 | colorMenu->setItemChecked(-19,TRUE); | 1558 | colorMenu->setItemChecked(-19,TRUE); |
1558 | } | 1559 | } |
1559 | #endif | 1560 | #endif |
1560 | 1561 | ||
1561 | lastSelectedMenu = iD; | 1562 | lastSelectedMenu = iD; |
1562 | 1563 | ||
1563 | setColors(foreground, background); | 1564 | setColors(foreground, background); |
1564 | 1565 | ||
1565 | QTabBar *tabBar = tab->getTabBar(); | 1566 | QTabBar *tabBar = tab->getTabBar(); |
1566 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | 1567 | QString ss = QString("Session%1").arg(tabBar->currentTab()); |
1567 | // printf("current tab = %d\n", tabBar->currentTab()); | 1568 | // printf("current tab = %d\n", tabBar->currentTab()); |
1568 | 1569 | ||
1569 | if (tabBar->currentTab() == 0) | 1570 | if (tabBar->currentTab() == 0) |
1570 | { | 1571 | { |
1571 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | 1572 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); |
1572 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | 1573 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); |
1573 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | 1574 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); |
1574 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | 1575 | cfg.writeEntry("backgroundRed",QString::number(background.red())); |
1575 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | 1576 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); |
1576 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | 1577 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); |
1577 | } | 1578 | } |
1578 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | 1579 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); |
1579 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | 1580 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); |
1580 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | 1581 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); |
1581 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | 1582 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); |
1582 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | 1583 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); |
1583 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | 1584 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); |
1584 | 1585 | ||
1585 | update(); | 1586 | update(); |
1586 | } | 1587 | } |
1587 | 1588 | ||
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,1197 +1,1195 @@ | |||
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()); |
811 | } else { | 809 | } else { |
812 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 810 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
813 | return false; | 811 | return false; |
814 | } | 812 | } |
815 | 813 | ||
816 | } | 814 | } |
817 | editor->setEdited( false); | 815 | editor->setEdited( false); |
818 | edited1=false; | 816 | edited1=false; |
819 | edited=false; | 817 | edited=false; |
820 | if(caption().left(1)=="*") | 818 | if(caption().left(1)=="*") |
821 | setCaption(caption().right(caption().length()-1)); | 819 | setCaption(caption().right(caption().length()-1)); |
822 | 820 | ||
823 | 821 | ||
824 | chmod( file.latin1(), mode); | 822 | chmod( file.latin1(), mode); |
825 | } | 823 | } |
826 | return true; | 824 | return true; |
827 | } | 825 | } |
828 | return false; | 826 | return false; |
829 | } | 827 | } |
830 | 828 | ||
831 | /*! | 829 | /*! |
832 | prompted save */ | 830 | prompted save */ |
833 | bool TextEdit::saveAs() { | 831 | bool TextEdit::saveAs() { |
834 | 832 | ||
835 | if(caption() == tr("Text Editor")) | 833 | if(caption() == tr("Text Editor")) |
836 | return false; | 834 | return false; |
837 | qDebug("saveAsFile " + currentFileName); | 835 | qDebug("saveAsFile " + currentFileName); |
838 | // case of nothing to save... | 836 | // case of nothing to save... |
839 | // if ( !doc && !currentFileName.isEmpty()) { | 837 | // if ( !doc && !currentFileName.isEmpty()) { |
840 | // //|| !bFromDocView) | 838 | // //|| !bFromDocView) |
841 | // qDebug("no doc"); | 839 | // qDebug("no doc"); |
842 | // return true; | 840 | // return true; |
843 | // } | 841 | // } |
844 | // if ( !editor->edited() ) { | 842 | // if ( !editor->edited() ) { |
845 | // delete doc; | 843 | // delete doc; |
846 | // doc = 0; | 844 | // doc = 0; |
847 | // return true; | 845 | // return true; |
848 | // } | 846 | // } |
849 | 847 | ||
850 | QString rt = editor->text(); | 848 | QString rt = editor->text(); |
851 | qDebug(currentFileName); | 849 | qDebug(currentFileName); |
852 | 850 | ||
853 | if( currentFileName.isEmpty() | 851 | if( currentFileName.isEmpty() |
854 | || currentFileName == tr("Unnamed") | 852 | || currentFileName == tr("Unnamed") |
855 | || currentFileName == tr("Text Editor")) { | 853 | || currentFileName == tr("Text Editor")) { |
856 | qDebug("do silly TT filename thing"); | 854 | qDebug("do silly TT filename thing"); |
857 | // if ( doc && doc->name().isEmpty() ) { | 855 | // if ( doc && doc->name().isEmpty() ) { |
858 | QString pt = rt.simplifyWhiteSpace(); | 856 | QString pt = rt.simplifyWhiteSpace(); |
859 | int i = pt.find( ' ' ); | 857 | int i = pt.find( ' ' ); |
860 | QString docname = pt; | 858 | QString docname = pt; |
861 | if ( i > 0 ) | 859 | if ( i > 0 ) |
862 | docname = pt.left( i ); | 860 | docname = pt.left( i ); |
863 | // remove "." at the beginning | 861 | // remove "." at the beginning |
864 | while( docname.startsWith( "." ) ) | 862 | while( docname.startsWith( "." ) ) |
865 | docname = docname.mid( 1 ); | 863 | docname = docname.mid( 1 ); |
866 | docname.replace( QRegExp("/"), "_" ); | 864 | docname.replace( QRegExp("/"), "_" ); |
867 | // cut the length. filenames longer than that | 865 | // cut the length. filenames longer than that |
868 | //don't make sense and something goes wrong when they get too long. | 866 | //don't make sense and something goes wrong when they get too long. |
869 | if ( docname.length() > 40 ) | 867 | if ( docname.length() > 40 ) |
870 | docname = docname.left(40); | 868 | docname = docname.left(40); |
871 | if ( docname.isEmpty() ) | 869 | if ( docname.isEmpty() ) |
872 | docname = tr("Unnamed"); | 870 | docname = tr("Unnamed"); |
873 | if(doc) doc->setName(docname); | 871 | if(doc) doc->setName(docname); |
874 | currentFileName=docname; | 872 | currentFileName=docname; |
875 | // } | 873 | // } |
876 | // else | 874 | // else |
877 | // qDebug("hmmmmmm"); | 875 | // qDebug("hmmmmmm"); |
878 | } | 876 | } |
879 | 877 | ||
880 | 878 | ||
881 | QMap<QString, QStringList> map; | 879 | QMap<QString, QStringList> map; |
882 | map.insert(tr("All"), QStringList() ); | 880 | map.insert(tr("All"), QStringList() ); |
883 | QStringList text; | 881 | QStringList text; |
884 | text << "text/*"; | 882 | text << "text/*"; |
885 | map.insert(tr("Text"), text ); | 883 | map.insert(tr("Text"), text ); |
886 | text << "*"; | 884 | text << "*"; |
887 | map.insert(tr("All"), text ); | 885 | map.insert(tr("All"), text ); |
888 | 886 | ||
889 | QFileInfo cuFi( currentFileName); | 887 | QFileInfo cuFi( currentFileName); |
890 | QString filee = cuFi.fileName(); | 888 | QString filee = cuFi.fileName(); |
891 | QString dire = cuFi.dirPath(); | 889 | QString dire = cuFi.dirPath(); |
892 | if(dire==".") | 890 | if(dire==".") |
893 | dire = QPEApplication::documentDir(); | 891 | dire = QPEApplication::documentDir(); |
894 | QString str; | 892 | QString str; |
895 | if( !featureAutoSave) { | 893 | if( !featureAutoSave) { |
896 | str = OFileDialog::getSaveFileName( 2, | 894 | str = OFileDialog::getSaveFileName( 2, |
897 | dire, | 895 | dire, |
898 | filee, map); | 896 | filee, map); |
899 | } else | 897 | } else |
900 | str=currentFileName; | 898 | str=currentFileName; |
901 | 899 | ||
902 | if(!str.isEmpty()) { | 900 | if(!str.isEmpty()) { |
903 | QString fileNm=str; | 901 | QString fileNm=str; |
904 | 902 | ||
905 | qDebug("saving filename "+fileNm); | 903 | qDebug("saving filename "+fileNm); |
906 | QFileInfo fi(fileNm); | 904 | QFileInfo fi(fileNm); |
907 | currentFileName=fi.fileName(); | 905 | currentFileName=fi.fileName(); |
908 | if(doc) | 906 | if(doc) |
909 | // QString file = doc->file(); | 907 | // QString file = doc->file(); |
910 | // doc->removeFiles(); | 908 | // doc->removeFiles(); |
911 | delete doc; | 909 | delete doc; |
912 | DocLnk nf; | 910 | DocLnk nf; |
913 | nf.setType("text/plain"); | 911 | nf.setType("text/plain"); |
914 | nf.setFile( fileNm); | 912 | nf.setFile( fileNm); |
915 | doc = new DocLnk(nf); | 913 | doc = new DocLnk(nf); |
916 | // editor->setText(rt); | 914 | // editor->setText(rt); |
917 | qDebug("Saving file as "+currentFileName); | 915 | qDebug("Saving file as "+currentFileName); |
918 | doc->setName( currentFileName); | 916 | doc->setName( currentFileName); |
919 | updateCaption( currentFileName); | 917 | updateCaption( currentFileName); |
920 | 918 | ||
921 | FileManager fm; | 919 | FileManager fm; |
922 | if ( !fm.saveFile( *doc, rt ) ) { | 920 | if ( !fm.saveFile( *doc, rt ) ) { |
923 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 921 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
924 | return false; | 922 | return false; |
925 | } | 923 | } |
926 | 924 | ||
927 | if( filePerms ) { | 925 | if( filePerms ) { |
928 | filePermissions *filePerm; | 926 | filePermissions *filePerm; |
929 | filePerm = new filePermissions(this, | 927 | filePerm = new filePermissions(this, |
930 | tr("Permissions"),true, | 928 | tr("Permissions"),true, |
931 | 0,(const QString &)fileNm); | 929 | 0,(const QString &)fileNm); |
932 | QPEApplication::execDialog( filePerm ); | 930 | QPEApplication::execDialog( filePerm ); |
933 | 931 | ||
934 | if( filePerm) | 932 | if( filePerm) |
935 | delete filePerm; | 933 | delete filePerm; |
936 | } | 934 | } |
937 | // } | 935 | // } |
938 | editor->setEdited( false); | 936 | editor->setEdited( false); |
939 | edited1 = false; | 937 | edited1 = false; |
940 | edited = false; | 938 | edited = false; |
941 | if(caption().left(1)=="*") | 939 | if(caption().left(1)=="*") |
942 | setCaption(caption().right(caption().length()-1)); | 940 | setCaption(caption().right(caption().length()-1)); |
943 | 941 | ||
944 | return true; | 942 | return true; |
945 | } | 943 | } |
946 | qDebug("returning false"); | 944 | qDebug("returning false"); |
947 | return false; | 945 | return false; |
948 | } //end saveAs | 946 | } //end saveAs |
949 | 947 | ||
950 | void TextEdit::clear() { | 948 | void TextEdit::clear() { |
951 | delete doc; | 949 | delete doc; |
952 | doc = 0; | 950 | doc = 0; |
953 | editor->clear(); | 951 | editor->clear(); |
954 | } | 952 | } |
955 | 953 | ||
956 | void TextEdit::updateCaption( const QString &name ) { | 954 | void TextEdit::updateCaption( const QString &name ) { |
957 | 955 | ||
958 | if ( name.isEmpty() ) | 956 | if ( name.isEmpty() ) |
959 | setCaption( tr("Text Editor") ); | 957 | setCaption( tr("Text Editor") ); |
960 | else { | 958 | else { |
961 | QString s = name; | 959 | QString s = name; |
962 | if ( s.isNull() ) | 960 | if ( s.isNull() ) |
963 | s = doc->name(); | 961 | s = doc->name(); |
964 | if ( s.isEmpty() ) { | 962 | if ( s.isEmpty() ) { |
965 | s = tr( "Unnamed" ); | 963 | s = tr( "Unnamed" ); |
966 | currentFileName=s; | 964 | currentFileName=s; |
967 | } | 965 | } |
968 | // if(s.left(1) == "/") | 966 | // if(s.left(1) == "/") |
969 | // s = s.right(s.length()-1); | 967 | // s = s.right(s.length()-1); |
970 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 968 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
971 | } | 969 | } |
972 | } | 970 | } |
973 | 971 | ||
974 | void TextEdit::setDocument(const QString& fileref) { | 972 | void TextEdit::setDocument(const QString& fileref) { |
975 | if(fileref != "Unnamed") { | 973 | if(fileref != "Unnamed") { |
976 | currentFileName=fileref; | 974 | currentFileName=fileref; |
977 | qDebug("setDocument"); | 975 | qDebug("setDocument"); |
978 | QFileInfo fi(currentFileName); | 976 | QFileInfo fi(currentFileName); |
979 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 977 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); |
980 | if( (fi.baseName().left(1)).isEmpty() ) { | 978 | if( (fi.baseName().left(1)).isEmpty() ) { |
981 | openDotFile(currentFileName); | 979 | openDotFile(currentFileName); |
982 | 980 | ||
983 | } else { | 981 | } else { |
984 | qDebug("setDoc open"); | 982 | qDebug("setDoc open"); |
985 | bFromDocView = true; | 983 | bFromDocView = true; |
986 | openFile(fileref); | 984 | openFile(fileref); |
987 | editor->setEdited(true); | 985 | editor->setEdited(true); |
988 | edited1=false; | 986 | edited1=false; |
989 | edited=true; | 987 | edited=true; |
990 | // fromSetDocument=false; | 988 | // fromSetDocument=false; |
991 | // doSearchBar(); | 989 | // doSearchBar(); |
992 | } | 990 | } |
993 | } | 991 | } |
994 | updateCaption( currentFileName); | 992 | updateCaption( currentFileName); |
995 | } | 993 | } |
996 | 994 | ||
997 | void TextEdit::changeFont() { | 995 | void TextEdit::changeFont() { |
998 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 996 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
999 | d-> setCaption ( tr( "Choose font" )); | 997 | d-> setCaption ( tr( "Choose font" )); |
1000 | QBoxLayout *lay = new QVBoxLayout ( d ); | 998 | QBoxLayout *lay = new QVBoxLayout ( d ); |
1001 | OFontSelector *ofs = new OFontSelector ( true, d ); | 999 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1002 | lay-> addWidget ( ofs ); | 1000 | lay-> addWidget ( ofs ); |
1003 | ofs-> setSelectedFont ( editor-> font ( )); | 1001 | ofs-> setSelectedFont ( editor-> font ( )); |
1004 | 1002 | ||
1005 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) | 1003 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1006 | editor-> setFont ( ofs-> selectedFont ( )); | 1004 | editor-> setFont ( ofs-> selectedFont ( )); |
1007 | delete d; | 1005 | delete d; |
1008 | 1006 | ||
1009 | } | 1007 | } |
1010 | 1008 | ||
1011 | void TextEdit::editDelete() { | 1009 | void TextEdit::editDelete() { |
1012 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1010 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1013 | tr("Do you really want<BR>to <B>delete</B> " | 1011 | tr("Do you really want<BR>to <B>delete</B> " |
1014 | "the current file\nfrom the disk?<BR>This is " | 1012 | "the current file\nfrom the disk?<BR>This is " |
1015 | "<B>irreversable!</B>"), | 1013 | "<B>irreversable!</B>"), |
1016 | tr("Yes"),tr("No"),0,0,1) ) { | 1014 | tr("Yes"),tr("No"),0,0,1) ) { |
1017 | case 0: | 1015 | case 0: |
1018 | if(doc) { | 1016 | if(doc) { |
1019 | doc->removeFiles(); | 1017 | doc->removeFiles(); |
1020 | clear(); | 1018 | clear(); |
1021 | setCaption( tr("Text Editor") ); | 1019 | setCaption( tr("Text Editor") ); |
1022 | } | 1020 | } |
1023 | break; | 1021 | break; |
1024 | case 1: | 1022 | case 1: |
1025 | // exit | 1023 | // exit |
1026 | break; | 1024 | break; |
1027 | }; | 1025 | }; |
1028 | } | 1026 | } |
1029 | 1027 | ||
1030 | void TextEdit::changeStartConfig( bool b ) { | 1028 | void TextEdit::changeStartConfig( bool b ) { |
1031 | startWithNew=b; | 1029 | startWithNew=b; |
1032 | Config cfg("TextEdit"); | 1030 | Config cfg("TextEdit"); |
1033 | cfg.setGroup("View"); | 1031 | cfg.setGroup("View"); |
1034 | cfg.writeEntry("startNew",b); | 1032 | cfg.writeEntry("startNew",b); |
1035 | update(); | 1033 | update(); |
1036 | } | 1034 | } |
1037 | 1035 | ||
1038 | void TextEdit::editorChanged() { | 1036 | void TextEdit::editorChanged() { |
1039 | // qDebug("editor changed"); | 1037 | // qDebug("editor changed"); |
1040 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1038 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1041 | setCaption( "*"+caption()); | 1039 | setCaption( "*"+caption()); |
1042 | edited1=true; | 1040 | edited1=true; |
1043 | } | 1041 | } |
1044 | edited=true; | 1042 | edited=true; |
1045 | } | 1043 | } |
1046 | 1044 | ||
1047 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1045 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1048 | qDebug("QCop "+msg); | 1046 | qDebug("QCop "+msg); |
1049 | if ( msg == "setDocument(QString)" ) { | 1047 | if ( msg == "setDocument(QString)" ) { |
1050 | qDebug("bugger all"); | 1048 | qDebug("bugger all"); |
1051 | 1049 | ||
1052 | } | 1050 | } |
1053 | 1051 | ||
1054 | } | 1052 | } |
1055 | 1053 | ||
1056 | void TextEdit::doAbout() { | 1054 | void TextEdit::doAbout() { |
1057 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1055 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1058 | "2000 Trolltech AS, and<BR>" | 1056 | "2000 Trolltech AS, and<BR>" |
1059 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1057 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1060 | "and is licensed under the GPL")); | 1058 | "and is licensed under the GPL")); |
1061 | } | 1059 | } |
1062 | 1060 | ||
1063 | void TextEdit::doPrompt(bool b) { | 1061 | void TextEdit::doPrompt(bool b) { |
1064 | promptExit=b; | 1062 | promptExit=b; |
1065 | Config cfg("TextEdit"); | 1063 | Config cfg("TextEdit"); |
1066 | cfg.setGroup ( "View" ); | 1064 | cfg.setGroup ( "View" ); |
1067 | cfg.writeEntry ( "PromptExit", b); | 1065 | cfg.writeEntry ( "PromptExit", b); |
1068 | } | 1066 | } |
1069 | 1067 | ||
1070 | void TextEdit::doDesktop(bool b) { | 1068 | void TextEdit::doDesktop(bool b) { |
1071 | openDesktop=b; | 1069 | openDesktop=b; |
1072 | Config cfg("TextEdit"); | 1070 | Config cfg("TextEdit"); |
1073 | cfg.setGroup ( "View" ); | 1071 | cfg.setGroup ( "View" ); |
1074 | cfg.writeEntry ( "OpenDesktop", b); | 1072 | cfg.writeEntry ( "OpenDesktop", b); |
1075 | } | 1073 | } |
1076 | 1074 | ||
1077 | void TextEdit::doFilePerms(bool b) { | 1075 | void TextEdit::doFilePerms(bool b) { |
1078 | filePerms=b; | 1076 | filePerms=b; |
1079 | Config cfg("TextEdit"); | 1077 | Config cfg("TextEdit"); |
1080 | cfg.setGroup ( "View" ); | 1078 | cfg.setGroup ( "View" ); |
1081 | cfg.writeEntry ( "FilePermissions", b); | 1079 | cfg.writeEntry ( "FilePermissions", b); |
1082 | } | 1080 | } |
1083 | 1081 | ||
1084 | void TextEdit::editPasteTimeDate() { | 1082 | void TextEdit::editPasteTimeDate() { |
1085 | #ifndef QT_NO_CLIPBOARD | 1083 | #ifndef QT_NO_CLIPBOARD |
1086 | QClipboard *cb = QApplication::clipboard(); | 1084 | QClipboard *cb = QApplication::clipboard(); |
1087 | QDateTime dt = QDateTime::currentDateTime(); | 1085 | QDateTime dt = QDateTime::currentDateTime(); |
1088 | cb->setText( dt.toString()); | 1086 | cb->setText( dt.toString()); |
1089 | editor->paste(); | 1087 | editor->paste(); |
1090 | #endif | 1088 | #endif |
1091 | } | 1089 | } |
1092 | 1090 | ||
1093 | int TextEdit::savePrompt() | 1091 | int TextEdit::savePrompt() |
1094 | { | 1092 | { |
1095 | switch( QMessageBox::information( 0, (tr("Textedit")), | 1093 | switch( QMessageBox::information( 0, (tr("Textedit")), |
1096 | (tr("Textedit detected\n" | 1094 | (tr("Textedit detected\n" |
1097 | "you have unsaved changes\n" | 1095 | "you have unsaved changes\n" |
1098 | "Go ahead and save?\n")), | 1096 | "Go ahead and save?\n")), |
1099 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | 1097 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) |
1100 | { | 1098 | { |
1101 | case 0: | 1099 | case 0: |
1102 | { | 1100 | { |
1103 | return 1; | 1101 | return 1; |
1104 | } | 1102 | } |
1105 | break; | 1103 | break; |
1106 | 1104 | ||
1107 | case 1: | 1105 | case 1: |
1108 | { | 1106 | { |
1109 | return 2; | 1107 | return 2; |
1110 | } | 1108 | } |
1111 | break; | 1109 | break; |
1112 | 1110 | ||
1113 | case 2: | 1111 | case 2: |
1114 | { | 1112 | { |
1115 | return -1; | 1113 | return -1; |
1116 | } | 1114 | } |
1117 | break; | 1115 | break; |
1118 | }; | 1116 | }; |
1119 | 1117 | ||
1120 | return 0; | 1118 | return 0; |
1121 | } | 1119 | } |
1122 | 1120 | ||
1123 | void TextEdit::timerCrank() | 1121 | void TextEdit::timerCrank() |
1124 | { | 1122 | { |
1125 | if(featureAutoSave && edited1) | 1123 | if(featureAutoSave && edited1) |
1126 | { | 1124 | { |
1127 | if(currentFileName.isEmpty()) | 1125 | if(currentFileName.isEmpty()) |
1128 | { | 1126 | { |
1129 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1127 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1130 | saveAs(); | 1128 | saveAs(); |
1131 | } | 1129 | } |
1132 | else | 1130 | else |
1133 | { | 1131 | { |
1134 | // qDebug("autosave"); | 1132 | // qDebug("autosave"); |
1135 | save(); | 1133 | save(); |
1136 | } | 1134 | } |
1137 | setTimer(); | 1135 | setTimer(); |
1138 | } | 1136 | } |
1139 | } | 1137 | } |
1140 | 1138 | ||
1141 | void TextEdit::doTimer(bool b) | 1139 | void TextEdit::doTimer(bool b) |
1142 | { | 1140 | { |
1143 | Config cfg("TextEdit"); | 1141 | Config cfg("TextEdit"); |
1144 | cfg.setGroup ( "View" ); | 1142 | cfg.setGroup ( "View" ); |
1145 | cfg.writeEntry ( "autosave", b); | 1143 | cfg.writeEntry ( "autosave", b); |
1146 | featureAutoSave = b; | 1144 | featureAutoSave = b; |
1147 | nAutoSave->setOn(b); | 1145 | nAutoSave->setOn(b); |
1148 | if(b) | 1146 | if(b) |
1149 | { | 1147 | { |
1150 | // qDebug("doTimer true"); | 1148 | // qDebug("doTimer true"); |
1151 | setTimer(); | 1149 | setTimer(); |
1152 | } | 1150 | } |
1153 | // else | 1151 | // else |
1154 | // qDebug("doTimer false"); | 1152 | // qDebug("doTimer false"); |
1155 | } | 1153 | } |
1156 | 1154 | ||
1157 | void TextEdit::setTimer() | 1155 | void TextEdit::setTimer() |
1158 | { | 1156 | { |
1159 | if(featureAutoSave) | 1157 | if(featureAutoSave) |
1160 | { | 1158 | { |
1161 | // qDebug("setting autosave"); | 1159 | // qDebug("setting autosave"); |
1162 | QTimer *timer = new QTimer(this ); | 1160 | QTimer *timer = new QTimer(this ); |
1163 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1161 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1164 | timer->start( 300000, true); //5 minutes | 1162 | timer->start( 300000, true); //5 minutes |
1165 | } | 1163 | } |
1166 | } | 1164 | } |
1167 | 1165 | ||
1168 | void TextEdit::gotoLine() { | 1166 | void TextEdit::gotoLine() { |
1169 | if( editor->length() < 1) | 1167 | if( editor->length() < 1) |
1170 | return; | 1168 | return; |
1171 | QWidget *d = QApplication::desktop(); | 1169 | QWidget *d = QApplication::desktop(); |
1172 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1170 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1173 | 1171 | ||
1174 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1172 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1175 | gotoEdit->setFrame(true); | 1173 | gotoEdit->setFrame(true); |
1176 | gotoEdit->show(); | 1174 | gotoEdit->show(); |
1177 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1175 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1178 | } | 1176 | } |
1179 | 1177 | ||
1180 | void TextEdit::doGoto() { | 1178 | void TextEdit::doGoto() { |
1181 | QString number = gotoEdit->text(); | 1179 | QString number = gotoEdit->text(); |
1182 | gotoEdit->hide(); | 1180 | gotoEdit->hide(); |
1183 | 1181 | ||
1184 | if(gotoEdit) { | 1182 | if(gotoEdit) { |
1185 | delete gotoEdit; | 1183 | delete gotoEdit; |
1186 | gotoEdit = 0; | 1184 | gotoEdit = 0; |
1187 | } | 1185 | } |
1188 | 1186 | ||
1189 | bool ok; | 1187 | bool ok; |
1190 | int lineNumber = number.toInt(&ok, 10); | 1188 | int lineNumber = number.toInt(&ok, 10); |
1191 | if( editor->numLines() < lineNumber) | 1189 | if( editor->numLines() < lineNumber) |
1192 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1190 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1193 | else | 1191 | else |
1194 | { | 1192 | { |
1195 | editor->setCursorPosition(lineNumber, 0, false); | 1193 | editor->setCursorPosition(lineNumber, 0, false); |
1196 | } | 1194 | } |
1197 | } | 1195 | } |
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 |