author | llornkcor <llornkcor> | 2002-12-05 18:36:11 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-05 18:36:11 (UTC) |
commit | 05757f4914d19f9c392be1e60e5ec972027886bf (patch) (unidiff) | |
tree | 0096190bb2cf832d90ca93968952b9eccf3d3149 | |
parent | 418fd5dab5503755aa1783d404576252684d4a96 (diff) | |
download | opie-05757f4914d19f9c392be1e60e5ec972027886bf.zip opie-05757f4914d19f9c392be1e60e5ec972027886bf.tar.gz opie-05757f4914d19f9c392be1e60e5ec972027886bf.tar.bz2 |
fix beep so all sessions are the same
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index 9be4674..275a9a8 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1060 +1,1058 @@ | |||
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 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | #define QT_QWS_OPIE | 22 | #define QT_QWS_OPIE |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qevent.h> | 27 | #include <qevent.h> |
28 | #include <qdragobject.h> | 28 | #include <qdragobject.h> |
29 | #include <qobjectlist.h> | 29 | #include <qobjectlist.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qpe/qpetoolbar.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | #include <qfontdialog.h> | 33 | #include <qfontdialog.h> |
34 | #include <qglobal.h> | 34 | #include <qglobal.h> |
35 | #include <qpainter.h> | 35 | #include <qpainter.h> |
36 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
37 | #include <qmessagebox.h> | 37 | #include <qmessagebox.h> |
38 | #include <qaction.h> | 38 | #include <qaction.h> |
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qfontmetrics.h> | 40 | #include <qfontmetrics.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qevent.h> | 42 | #include <qevent.h> |
43 | #include <qtabwidget.h> | 43 | #include <qtabwidget.h> |
44 | #include <qtabbar.h> | 44 | #include <qtabbar.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qpalette.h> | 47 | #include <qpalette.h> |
48 | 48 | ||
49 | #include <sys/wait.h> | 49 | #include <sys/wait.h> |
50 | #include <stdio.h> | 50 | #include <stdio.h> |
51 | #include <stdlib.h> | 51 | #include <stdlib.h> |
52 | #include <assert.h> | 52 | #include <assert.h> |
53 | 53 | ||
54 | #include "konsole.h" | 54 | #include "konsole.h" |
55 | #include "keytrans.h" | 55 | #include "keytrans.h" |
56 | #include "commandeditdialog.h" | 56 | #include "commandeditdialog.h" |
57 | 57 | ||
58 | #ifdef QT_QWS_OPIE | 58 | #ifdef QT_QWS_OPIE |
59 | #include <opie/colorpopupmenu.h> | 59 | #include <opie/colorpopupmenu.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | class EKNumTabBar : public QTabBar { | 62 | class EKNumTabBar : public QTabBar { |
63 | public: | 63 | public: |
64 | void numberTabs() | 64 | void numberTabs() |
65 | { | 65 | { |
66 | // Yes, it really is this messy. QTabWidget needs functions | 66 | // Yes, it really is this messy. QTabWidget needs functions |
67 | // that provide acces to tabs in a sequential way. | 67 | // that provide acces to tabs in a sequential way. |
68 | int m=INT_MIN; | 68 | int m=INT_MIN; |
69 | for (int i=0; i<count(); i++) { | 69 | for (int i=0; i<count(); i++) { |
70 | QTab* left=0; | 70 | QTab* left=0; |
71 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
72 | int x=INT_MAX; | 72 | int x=INT_MAX; |
73 | for( QTab* t; (t=it.current()); ++it ) { | 73 | for( QTab* t; (t=it.current()); ++it ) { |
74 | int tx = t->rect().x(); | 74 | int tx = t->rect().x(); |
75 | if ( tx<x && tx>m ) { | 75 | if ( tx<x && tx>m ) { |
76 | x = tx; | 76 | x = tx; |
77 | left = t; | 77 | left = t; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | if ( left ) { | 80 | if ( left ) { |
81 | left->setText(QString::number(i+1)); | 81 | left->setText(QString::number(i+1)); |
82 | m = left->rect().x(); | 82 | m = left->rect().x(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | } | 85 | } |
86 | }; | 86 | }; |
87 | 87 | ||
88 | class EKNumTabWidget : public QTabWidget { | 88 | class EKNumTabWidget : public QTabWidget { |
89 | public: | 89 | public: |
90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 90 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
91 | { | 91 | { |
92 | } | 92 | } |
93 | 93 | ||
94 | void addTab(QWidget* w) | 94 | void addTab(QWidget* w) |
95 | { | 95 | { |
96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 96 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
97 | QTabWidget::addTab(w,t); | 97 | QTabWidget::addTab(w,t); |
98 | } | 98 | } |
99 | 99 | ||
100 | void removeTab(QWidget* w) | 100 | void removeTab(QWidget* w) |
101 | { | 101 | { |
102 | removePage(w); | 102 | removePage(w); |
103 | ((EKNumTabBar*)tabBar())->numberTabs(); | 103 | ((EKNumTabBar*)tabBar())->numberTabs(); |
104 | } | 104 | } |
105 | }; | 105 | }; |
106 | 106 | ||
107 | // This could be configurable or dynamicly generated from the bash history | 107 | // This could be configurable or dynamicly generated from the bash history |
108 | // file of the user | 108 | // file of the user |
109 | static const char *commonCmds[] = | 109 | static const char *commonCmds[] = |
110 | { | 110 | { |
111 | "ls ", // I left this here, cause it looks better than the first alpha | 111 | "ls ", // I left this here, cause it looks better than the first alpha |
112 | "cardctl eject", | 112 | "cardctl eject", |
113 | "cat ", | 113 | "cat ", |
114 | "cd ", | 114 | "cd ", |
115 | "chmod ", | 115 | "chmod ", |
116 | "clear", | 116 | "clear", |
117 | "cp ", | 117 | "cp ", |
118 | "dc ", | 118 | "dc ", |
119 | "df ", | 119 | "df ", |
120 | "dmesg", | 120 | "dmesg", |
121 | "echo ", | 121 | "echo ", |
122 | "env", | 122 | "env", |
123 | "find ", | 123 | "find ", |
124 | "free", | 124 | "free", |
125 | "grep ", | 125 | "grep ", |
126 | "ifconfig ", | 126 | "ifconfig ", |
127 | "ipkg ", | 127 | "ipkg ", |
128 | "mkdir ", | 128 | "mkdir ", |
129 | "mv ", | 129 | "mv ", |
130 | "nc localhost 7776", | 130 | "nc localhost 7776", |
131 | "nc localhost 7777", | 131 | "nc localhost 7777", |
132 | "netstat ", | 132 | "netstat ", |
133 | "nslookup ", | 133 | "nslookup ", |
134 | "ping ", | 134 | "ping ", |
135 | "ps aux", | 135 | "ps aux", |
136 | "pwd ", | 136 | "pwd ", |
137 | "qcop QPE/System 'linkChanged(QString)' ''", | 137 | "qcop QPE/System 'linkChanged(QString)' ''", |
138 | "qcop QPE/System 'restart()'", | 138 | "qcop QPE/System 'restart()'", |
139 | "qcop QPE/System 'quit()'", | 139 | "qcop QPE/System 'quit()'", |
140 | "rm ", | 140 | "rm ", |
141 | "rmdir ", | 141 | "rmdir ", |
142 | "route ", | 142 | "route ", |
143 | "set ", | 143 | "set ", |
144 | "traceroute", | 144 | "traceroute", |
145 | 145 | ||
146 | /* | 146 | /* |
147 | "gzip", | 147 | "gzip", |
148 | "gunzip", | 148 | "gunzip", |
149 | "chgrp", | 149 | "chgrp", |
150 | "chown", | 150 | "chown", |
151 | "date", | 151 | "date", |
152 | "dd", | 152 | "dd", |
153 | "df", | 153 | "df", |
154 | "dmesg", | 154 | "dmesg", |
155 | "fuser", | 155 | "fuser", |
156 | "hostname", | 156 | "hostname", |
157 | "kill", | 157 | "kill", |
158 | "killall", | 158 | "killall", |
159 | "ln", | 159 | "ln", |
160 | "ping", | 160 | "ping", |
161 | "mount", | 161 | "mount", |
162 | "more", | 162 | "more", |
163 | "sort", | 163 | "sort", |
164 | "touch", | 164 | "touch", |
165 | "umount", | 165 | "umount", |
166 | "mknod", | 166 | "mknod", |
167 | "netstat", | 167 | "netstat", |
168 | */ | 168 | */ |
169 | 169 | ||
170 | "exit", | 170 | "exit", |
171 | NULL | 171 | NULL |
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 175 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
176 | QMainWindow(parent, name, fl) | 176 | QMainWindow(parent, name, fl) |
177 | { | 177 | { |
178 | QStrList args; | 178 | QStrList args; |
179 | init("/bin/sh",args); | 179 | init("/bin/sh",args); |
180 | } | 180 | } |
181 | 181 | ||
182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 182 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
183 | : QMainWindow(0, name) | 183 | : QMainWindow(0, name) |
184 | { | 184 | { |
185 | init(_pgm,_args); | 185 | init(_pgm,_args); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Konsole::initCommandList() | 188 | void Konsole::initCommandList() |
189 | { | 189 | { |
190 | // qDebug("Konsole::initCommandList"); | 190 | // qDebug("Konsole::initCommandList"); |
191 | Config cfg("Konsole"); | 191 | Config cfg("Konsole"); |
192 | cfg.setGroup("Commands"); | 192 | cfg.setGroup("Commands"); |
193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 193 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
194 | commonCombo->clear(); | 194 | commonCombo->clear(); |
195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 195 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
196 | for (int i = 0; commonCmds[i] != NULL; i++) { | 196 | for (int i = 0; commonCmds[i] != NULL; i++) { |
197 | commonCombo->insertItem(commonCmds[i],i); | 197 | commonCombo->insertItem(commonCmds[i],i); |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | for (int i = 0; i < 100; i++) { | 200 | for (int i = 0; i < 100; i++) { |
201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 201 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 202 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | } | 206 | } |
207 | 207 | ||
208 | void Konsole::init(const char* _pgm, QStrList & _args) | 208 | void Konsole::init(const char* _pgm, QStrList & _args) |
209 | { | 209 | { |
210 | b_scroll = TRUE; // histon; | 210 | b_scroll = TRUE; // histon; |
211 | n_keytab = 0; | 211 | n_keytab = 0; |
212 | n_render = 0; | 212 | n_render = 0; |
213 | startUp=0; | 213 | startUp=0; |
214 | fromMenu = FALSE; | 214 | fromMenu = FALSE; |
215 | 215 | ||
216 | setCaption( tr("Terminal") ); | 216 | setCaption( tr("Terminal") ); |
217 | setIcon( Resource::loadPixmap( "konsole" ) ); | 217 | setIcon( Resource::loadPixmap( "konsole" ) ); |
218 | 218 | ||
219 | Config cfg("Konsole"); | 219 | Config cfg("Konsole"); |
220 | cfg.setGroup("Konsole"); | 220 | cfg.setGroup("Konsole"); |
221 | QString tmp; | 221 | QString tmp; |
222 | // initialize the list of allowed fonts /////////////////////////////////// | 222 | // initialize the list of allowed fonts /////////////////////////////////// |
223 | cfont = cfg.readNumEntry("FontID", 1); | 223 | cfont = cfg.readNumEntry("FontID", 1); |
224 | QFont f = QFont("Micro", 4, QFont::Normal); | 224 | QFont f = QFont("Micro", 4, QFont::Normal); |
225 | f.setFixedPitch(TRUE); | 225 | f.setFixedPitch(TRUE); |
226 | fonts.append(new VTFont(tr("Micro"), f)); | 226 | fonts.append(new VTFont(tr("Micro"), f)); |
227 | 227 | ||
228 | f = QFont("Fixed", 7, QFont::Normal); | 228 | f = QFont("Fixed", 7, QFont::Normal); |
229 | f.setFixedPitch(TRUE); | 229 | f.setFixedPitch(TRUE); |
230 | fonts.append(new VTFont(tr("Small Fixed"), f)); | 230 | fonts.append(new VTFont(tr("Small Fixed"), f)); |
231 | 231 | ||
232 | f = QFont("Fixed", 12, QFont::Normal); | 232 | f = QFont("Fixed", 12, QFont::Normal); |
233 | f.setFixedPitch(TRUE); | 233 | f.setFixedPitch(TRUE); |
234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | 234 | fonts.append(new VTFont(tr("Medium Fixed"), f)); |
235 | 235 | ||
236 | // create terminal emulation framework //////////////////////////////////// | 236 | // create terminal emulation framework //////////////////////////////////// |
237 | nsessions = 0; | 237 | nsessions = 0; |
238 | 238 | ||
239 | tab = new EKNumTabWidget(this); | 239 | tab = new EKNumTabWidget(this); |
240 | 240 | ||
241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 241 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
242 | 242 | ||
243 | // create terminal toolbar //////////////////////////////////////////////// | 243 | // create terminal toolbar //////////////////////////////////////////////// |
244 | setToolBarsMovable( FALSE ); | 244 | setToolBarsMovable( FALSE ); |
245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); | 245 | QPEToolBar *menuToolBar = new QPEToolBar( this ); |
246 | menuToolBar->setHorizontalStretchable( TRUE ); | 246 | menuToolBar->setHorizontalStretchable( TRUE ); |
247 | 247 | ||
248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); | 248 | QPEMenuBar *menuBar = new QPEMenuBar( menuToolBar ); |
249 | 249 | ||
250 | fontList = new QPopupMenu( this ); | 250 | fontList = new QPopupMenu( this ); |
251 | for(uint i = 0; i < fonts.count(); i++) { | 251 | for(uint i = 0; i < fonts.count(); i++) { |
252 | VTFont *fnt = fonts.at(i); | 252 | VTFont *fnt = fonts.at(i); |
253 | fontList->insertItem(fnt->getName(), i); | 253 | fontList->insertItem(fnt->getName(), i); |
254 | } | 254 | } |
255 | fontChanged(cfont); | 255 | fontChanged(cfont); |
256 | 256 | ||
257 | configMenu = new QPopupMenu( this); | 257 | configMenu = new QPopupMenu( this); |
258 | colorMenu = new QPopupMenu( this); | 258 | colorMenu = new QPopupMenu( this); |
259 | scrollMenu = new QPopupMenu( this); | 259 | scrollMenu = new QPopupMenu( this); |
260 | editCommandListMenu = new QPopupMenu( this); | 260 | editCommandListMenu = new QPopupMenu( this); |
261 | 261 | ||
262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 262 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
263 | 263 | ||
264 | bool listHidden; | 264 | bool listHidden; |
265 | cfg.setGroup("Menubar"); | 265 | cfg.setGroup("Menubar"); |
266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | 266 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { |
267 | editCommandListMenu->insertItem( tr( "Show command list" )); | 267 | editCommandListMenu->insertItem( tr( "Show command list" )); |
268 | listHidden=TRUE; | 268 | listHidden=TRUE; |
269 | } else { | 269 | } else { |
270 | editCommandListMenu->insertItem( tr( "Hide command list" )); | 270 | editCommandListMenu->insertItem( tr( "Hide command list" )); |
271 | listHidden=FALSE; | 271 | listHidden=FALSE; |
272 | } | 272 | } |
273 | 273 | ||
274 | cfg.setGroup("Tabs"); | 274 | cfg.setGroup("Tabs"); |
275 | tmp=cfg.readEntry("Position","Bottom"); | 275 | tmp=cfg.readEntry("Position","Bottom"); |
276 | if(tmp=="Top") { | 276 | if(tmp=="Top") { |
277 | tab->setTabPosition(QTabWidget::Top); | 277 | tab->setTabPosition(QTabWidget::Top); |
278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 278 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); |
279 | } else { | 279 | } else { |
280 | tab->setTabPosition(QTabWidget::Bottom); | 280 | tab->setTabPosition(QTabWidget::Bottom); |
281 | configMenu->insertItem(tr("Tabs on Top")); | 281 | configMenu->insertItem(tr("Tabs on Top")); |
282 | } | 282 | } |
283 | configMenu->insertSeparator(2); | 283 | configMenu->insertSeparator(2); |
284 | 284 | ||
285 | colorMenu->insertItem(tr( "Green on Black")); | 285 | colorMenu->insertItem(tr( "Green on Black")); |
286 | colorMenu->insertItem(tr( "Black on White")); | 286 | colorMenu->insertItem(tr( "Black on White")); |
287 | colorMenu->insertItem(tr( "White on Black")); | 287 | colorMenu->insertItem(tr( "White on Black")); |
288 | colorMenu->insertItem(tr( "Black on Transparent")); | 288 | colorMenu->insertItem(tr( "Black on Transparent")); |
289 | colorMenu->insertItem(tr( "Black on Red")); | 289 | colorMenu->insertItem(tr( "Black on Red")); |
290 | colorMenu->insertItem(tr( "Red on Black")); | 290 | colorMenu->insertItem(tr( "Red on Black")); |
291 | colorMenu->insertItem(tr( "Green on Yellow")); | 291 | colorMenu->insertItem(tr( "Green on Yellow")); |
292 | colorMenu->insertItem(tr( "Blue on Magenta")); | 292 | colorMenu->insertItem(tr( "Blue on Magenta")); |
293 | colorMenu->insertItem(tr( "Magenta on Blue")); | 293 | colorMenu->insertItem(tr( "Magenta on Blue")); |
294 | colorMenu->insertItem(tr( "Cyan on White")); | 294 | colorMenu->insertItem(tr( "Cyan on White")); |
295 | colorMenu->insertItem(tr( "White on Cyan")); | 295 | colorMenu->insertItem(tr( "White on Cyan")); |
296 | colorMenu->insertItem(tr( "Blue on Black")); | 296 | colorMenu->insertItem(tr( "Blue on Black")); |
297 | colorMenu->insertItem(tr( "Amber on Black")); | 297 | colorMenu->insertItem(tr( "Amber on Black")); |
298 | 298 | ||
299 | #ifdef QT_QWS_OPIE | 299 | #ifdef QT_QWS_OPIE |
300 | colorMenu->insertItem(tr( "Custom")); | 300 | colorMenu->insertItem(tr( "Custom")); |
301 | #endif | 301 | #endif |
302 | 302 | ||
303 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 303 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
304 | 304 | ||
305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 305 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 306 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 307 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 308 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 309 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
310 | menuBar->insertItem( tr("Font"), fontList ); | 310 | menuBar->insertItem( tr("Font"), fontList ); |
311 | menuBar->insertItem( tr("Options"), configMenu ); | 311 | menuBar->insertItem( tr("Options"), configMenu ); |
312 | 312 | ||
313 | QPEToolBar *toolbar = new QPEToolBar( this ); | 313 | QPEToolBar *toolbar = new QPEToolBar( this ); |
314 | 314 | ||
315 | QAction *a; | 315 | QAction *a; |
316 | 316 | ||
317 | // Button Commands | 317 | // Button Commands |
318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | 318 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); |
319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | 319 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); |
320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 320 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); |
321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | 321 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); |
322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 322 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); |
323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | 323 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); |
324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 324 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); |
325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | 325 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); |
326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 326 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); |
327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 327 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 328 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); |
329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 329 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 330 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | 331 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); |
332 | /* | 332 | /* |
333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 333 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); |
335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 335 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | 336 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); |
337 | */ | 337 | */ |
338 | 338 | ||
339 | secondToolBar = new QPEToolBar( this ); | 339 | secondToolBar = new QPEToolBar( this ); |
340 | secondToolBar->setHorizontalStretchable( TRUE ); | 340 | secondToolBar->setHorizontalStretchable( TRUE ); |
341 | 341 | ||
342 | commonCombo = new QComboBox( secondToolBar ); | 342 | commonCombo = new QComboBox( secondToolBar ); |
343 | commonCombo->setMaximumWidth(236); | 343 | commonCombo->setMaximumWidth(236); |
344 | 344 | ||
345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 345 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
346 | if( listHidden) { | 346 | if( listHidden) { |
347 | secondToolBar->hide(); | 347 | secondToolBar->hide(); |
348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 348 | editCommandListMenu->setItemEnabled(-23 ,FALSE); |
349 | } | 349 | } |
350 | editCommandListMenu->insertItem(tr( "Edit" ) ); | 350 | editCommandListMenu->insertItem(tr( "Edit" ) ); |
351 | 351 | ||
352 | cfg.setGroup("Commands"); | 352 | cfg.setGroup("Commands"); |
353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 353 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
354 | 354 | ||
355 | initCommandList(); | 355 | initCommandList(); |
356 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 356 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
357 | // commonCombo->insertItem( commonCmds[i], i ); | 357 | // commonCombo->insertItem( commonCmds[i], i ); |
358 | // tmp = cfg.readEntry( QString::number(i),""); | 358 | // tmp = cfg.readEntry( QString::number(i),""); |
359 | // if(tmp != "") | 359 | // if(tmp != "") |
360 | // commonCombo->changeItem( tmp,i ); | 360 | // commonCombo->changeItem( tmp,i ); |
361 | // } | 361 | // } |
362 | 362 | ||
363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 363 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
364 | 364 | ||
365 | scrollMenu->insertItem(tr( "None" )); | 365 | scrollMenu->insertItem(tr( "None" )); |
366 | scrollMenu->insertItem(tr( "Left" )); | 366 | scrollMenu->insertItem(tr( "Left" )); |
367 | scrollMenu->insertItem(tr( "Right" )); | 367 | scrollMenu->insertItem(tr( "Right" )); |
368 | // scrollMenu->insertSeparator(4); | 368 | // scrollMenu->insertSeparator(4); |
369 | // scrollMenu->insertItem(tr( "Horizontal" )); | 369 | // scrollMenu->insertItem(tr( "Horizontal" )); |
370 | 370 | ||
371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 371 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
372 | 372 | ||
373 | int jut = configMenu->insertItem(tr( "Wrap" )); | 373 | int jut = configMenu->insertItem(tr( "Wrap" )); |
374 | cfg.setGroup("ScrollBar"); | 374 | cfg.setGroup("ScrollBar"); |
375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 375 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); |
376 | 376 | ||
377 | jut = configMenu->insertItem(tr( "Use Beep" )); | 377 | jut = configMenu->insertItem(tr( "Use Beep" )); |
378 | cfg.setGroup("Menubar"); | 378 | cfg.setGroup("Menubar"); |
379 | 379 | ||
380 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 380 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); |
381 | 381 | ||
382 | 382 | ||
383 | //scrollMenuSelected(-29); | 383 | //scrollMenuSelected(-29); |
384 | // cfg.setGroup("ScrollBar"); | 384 | // cfg.setGroup("ScrollBar"); |
385 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 385 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
386 | // if(cfg.readNumEntry("Position",2) == 0) | 386 | // if(cfg.readNumEntry("Position",2) == 0) |
387 | // te->setScrollbarLocation(1); | 387 | // te->setScrollbarLocation(1); |
388 | // else | 388 | // else |
389 | // te->setScrollbarLocation(0); | 389 | // te->setScrollbarLocation(0); |
390 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 390 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
391 | // te->setWrapAt(120); | 391 | // te->setWrapAt(120); |
392 | // } | 392 | // } |
393 | // create applications ///////////////////////////////////////////////////// | 393 | // create applications ///////////////////////////////////////////////////// |
394 | setCentralWidget(tab); | 394 | setCentralWidget(tab); |
395 | 395 | ||
396 | // load keymaps //////////////////////////////////////////////////////////// | 396 | // load keymaps //////////////////////////////////////////////////////////// |
397 | KeyTrans::loadAll(); | 397 | KeyTrans::loadAll(); |
398 | for (int i = 0; i < KeyTrans::count(); i++) | 398 | for (int i = 0; i < KeyTrans::count(); i++) |
399 | { KeyTrans* s = KeyTrans::find(i); | 399 | { KeyTrans* s = KeyTrans::find(i); |
400 | assert( s ); | 400 | assert( s ); |
401 | } | 401 | } |
402 | 402 | ||
403 | se_pgm = _pgm; | 403 | se_pgm = _pgm; |
404 | se_args = _args; | 404 | se_args = _args; |
405 | se_args.prepend("--login"); | 405 | se_args.prepend("--login"); |
406 | parseCommandLine(); | 406 | parseCommandLine(); |
407 | // read and apply default values /////////////////////////////////////////// | 407 | // read and apply default values /////////////////////////////////////////// |
408 | resize(321, 321); // Dummy. | 408 | resize(321, 321); // Dummy. |
409 | QSize currentSize = size(); | 409 | QSize currentSize = size(); |
410 | if (currentSize != size()) | 410 | if (currentSize != size()) |
411 | defaultSize = size(); | 411 | defaultSize = size(); |
412 | } | 412 | } |
413 | 413 | ||
414 | void Konsole::show() | 414 | void Konsole::show() |
415 | { | 415 | { |
416 | if ( !nsessions ) { | 416 | if ( !nsessions ) { |
417 | newSession(); | 417 | newSession(); |
418 | } | 418 | } |
419 | QMainWindow::show(); | 419 | QMainWindow::show(); |
420 | 420 | ||
421 | } | 421 | } |
422 | 422 | ||
423 | void Konsole::initSession(const char*, QStrList &) | 423 | void Konsole::initSession(const char*, QStrList &) |
424 | { | 424 | { |
425 | QMainWindow::show(); | 425 | QMainWindow::show(); |
426 | } | 426 | } |
427 | 427 | ||
428 | Konsole::~Konsole() | 428 | Konsole::~Konsole() |
429 | { | 429 | { |
430 | while (nsessions > 0) { | 430 | while (nsessions > 0) { |
431 | doneSession(getTe()->currentSession, 0); | 431 | doneSession(getTe()->currentSession, 0); |
432 | } | 432 | } |
433 | 433 | ||
434 | Config cfg("Konsole"); | 434 | Config cfg("Konsole"); |
435 | cfg.setGroup("Konsole"); | 435 | cfg.setGroup("Konsole"); |
436 | cfg.writeEntry("FontID", cfont); | 436 | cfg.writeEntry("FontID", cfont); |
437 | } | 437 | } |
438 | 438 | ||
439 | void Konsole::fontChanged(int f) | 439 | void Konsole::fontChanged(int f) |
440 | { | 440 | { |
441 | VTFont* font = fonts.at(f); | 441 | VTFont* font = fonts.at(f); |
442 | if (font != 0) { | 442 | if (font != 0) { |
443 | for(uint i = 0; i < fonts.count(); i++) { | 443 | for(uint i = 0; i < fonts.count(); i++) { |
444 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 444 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
445 | } | 445 | } |
446 | 446 | ||
447 | cfont = f; | 447 | cfont = f; |
448 | 448 | ||
449 | TEWidget* te = getTe(); | 449 | TEWidget* te = getTe(); |
450 | if (te != 0) { | 450 | if (te != 0) { |
451 | te->setVTFont(font->getFont()); | 451 | te->setVTFont(font->getFont()); |
452 | } | 452 | } |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | void Konsole::enterCommand(int c) | 457 | void Konsole::enterCommand(int c) |
458 | { | 458 | { |
459 | TEWidget* te = getTe(); | 459 | TEWidget* te = getTe(); |
460 | if (te != 0) { | 460 | if (te != 0) { |
461 | if(!commonCombo->editable()) { | 461 | if(!commonCombo->editable()) { |
462 | QString text = commonCombo->text(c); //commonCmds[c]; | 462 | QString text = commonCombo->text(c); //commonCmds[c]; |
463 | te->emitText(text); | 463 | te->emitText(text); |
464 | } else { | 464 | } else { |
465 | changeCommand( commonCombo->text(c), c); | 465 | changeCommand( commonCombo->text(c), c); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | } | 468 | } |
469 | 469 | ||
470 | void Konsole::hitEnter() | 470 | void Konsole::hitEnter() |
471 | { | 471 | { |
472 | TEWidget* te = getTe(); | 472 | TEWidget* te = getTe(); |
473 | if (te != 0) { | 473 | if (te != 0) { |
474 | te->emitText(QString("\r")); | 474 | te->emitText(QString("\r")); |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | void Konsole::hitSpace() | 478 | void Konsole::hitSpace() |
479 | { | 479 | { |
480 | TEWidget* te = getTe(); | 480 | TEWidget* te = getTe(); |
481 | if (te != 0) { | 481 | if (te != 0) { |
482 | te->emitText(QString(" ")); | 482 | te->emitText(QString(" ")); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | 485 | ||
486 | void Konsole::hitTab() | 486 | void Konsole::hitTab() |
487 | { | 487 | { |
488 | TEWidget* te = getTe(); | 488 | TEWidget* te = getTe(); |
489 | if (te != 0) { | 489 | if (te != 0) { |
490 | te->emitText(QString("\t")); | 490 | te->emitText(QString("\t")); |
491 | } | 491 | } |
492 | } | 492 | } |
493 | 493 | ||
494 | void Konsole::hitPaste() | 494 | void Konsole::hitPaste() |
495 | { | 495 | { |
496 | TEWidget* te = getTe(); | 496 | TEWidget* te = getTe(); |
497 | if (te != 0) { | 497 | if (te != 0) { |
498 | te->pasteClipboard(); | 498 | te->pasteClipboard(); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | void Konsole::hitUp() | 502 | void Konsole::hitUp() |
503 | { | 503 | { |
504 | TEWidget* te = getTe(); | 504 | TEWidget* te = getTe(); |
505 | if (te != 0) { | 505 | if (te != 0) { |
506 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 506 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
507 | QApplication::sendEvent( te, &ke ); | 507 | QApplication::sendEvent( te, &ke ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | void Konsole::hitDown() | 511 | void Konsole::hitDown() |
512 | { | 512 | { |
513 | TEWidget* te = getTe(); | 513 | TEWidget* te = getTe(); |
514 | if (te != 0) { | 514 | if (te != 0) { |
515 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 515 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
516 | QApplication::sendEvent( te, &ke ); | 516 | QApplication::sendEvent( te, &ke ); |
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | /** | 520 | /** |
521 | This function calculates the size of the external widget | 521 | This function calculates the size of the external widget |
522 | needed for the internal widget to be | 522 | needed for the internal widget to be |
523 | */ | 523 | */ |
524 | QSize Konsole::calcSize(int columns, int lines) { | 524 | QSize Konsole::calcSize(int columns, int lines) { |
525 | TEWidget* te = getTe(); | 525 | TEWidget* te = getTe(); |
526 | if (te != 0) { | 526 | if (te != 0) { |
527 | QSize size = te->calcSize(columns, lines); | 527 | QSize size = te->calcSize(columns, lines); |
528 | return size; | 528 | return size; |
529 | } else { | 529 | } else { |
530 | QSize size; | 530 | QSize size; |
531 | return size; | 531 | return size; |
532 | } | 532 | } |
533 | } | 533 | } |
534 | 534 | ||
535 | /** | 535 | /** |
536 | sets application window to a size based on columns X lines of the te | 536 | sets application window to a size based on columns X lines of the te |
537 | guest widget. Call with (0,0) for setting default size. | 537 | guest widget. Call with (0,0) for setting default size. |
538 | */ | 538 | */ |
539 | 539 | ||
540 | void Konsole::setColLin(int columns, int lines) | 540 | void Konsole::setColLin(int columns, int lines) |
541 | { | 541 | { |
542 | qDebug("konsole::setColLin:: Columns %d", columns); | 542 | qDebug("konsole::setColLin:: Columns %d", columns); |
543 | 543 | ||
544 | if ((columns==0) || (lines==0)) | 544 | if ((columns==0) || (lines==0)) |
545 | { | 545 | { |
546 | if (defaultSize.isEmpty()) // not in config file : set default value | 546 | if (defaultSize.isEmpty()) // not in config file : set default value |
547 | { | 547 | { |
548 | defaultSize = calcSize(80,24); | 548 | defaultSize = calcSize(80,24); |
549 | // notifySize(24,80); // set menu items (strange arg order !) | 549 | // notifySize(24,80); // set menu items (strange arg order !) |
550 | } | 550 | } |
551 | resize(defaultSize); | 551 | resize(defaultSize); |
552 | } else { | 552 | } else { |
553 | resize(calcSize(columns, lines)); | 553 | resize(calcSize(columns, lines)); |
554 | // notifySize(lines,columns); // set menu items (strange arg order !) | 554 | // notifySize(lines,columns); // set menu items (strange arg order !) |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | /* | 558 | /* |
559 | void Konsole::setFont(int fontno) | 559 | void Konsole::setFont(int fontno) |
560 | { | 560 | { |
561 | QFont f; | 561 | QFont f; |
562 | if (fontno == 0) | 562 | if (fontno == 0) |
563 | f = defaultFont = QFont( "Helvetica", 12 ); | 563 | f = defaultFont = QFont( "Helvetica", 12 ); |
564 | else | 564 | else |
565 | if (fonts[fontno][0] == '-') | 565 | if (fonts[fontno][0] == '-') |
566 | f.setRawName( fonts[fontno] ); | 566 | f.setRawName( fonts[fontno] ); |
567 | else | 567 | else |
568 | { | 568 | { |
569 | f.setFamily(fonts[fontno]); | 569 | f.setFamily(fonts[fontno]); |
570 | f.setRawMode( TRUE ); | 570 | f.setRawMode( TRUE ); |
571 | } | 571 | } |
572 | if ( !f.exactMatch() && fontno != 0) | 572 | if ( !f.exactMatch() && fontno != 0) |
573 | { | 573 | { |
574 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 574 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
575 | QMessageBox(this, msg); | 575 | QMessageBox(this, msg); |
576 | return; | 576 | return; |
577 | } | 577 | } |
578 | if (se) se->setFontNo(fontno); | 578 | if (se) se->setFontNo(fontno); |
579 | te->setVTFont(f); | 579 | te->setVTFont(f); |
580 | n_font = fontno; | 580 | n_font = fontno; |
581 | } | 581 | } |
582 | */ | 582 | */ |
583 | 583 | ||
584 | // --| color selection |------------------------------------------------------- | 584 | // --| color selection |------------------------------------------------------- |
585 | 585 | ||
586 | void Konsole::changeColumns(int columns) | 586 | void Konsole::changeColumns(int columns) |
587 | { | 587 | { |
588 | qDebug("change columns"); | 588 | qDebug("change columns"); |
589 | TEWidget* te = getTe(); | 589 | TEWidget* te = getTe(); |
590 | if (te != 0) { | 590 | if (te != 0) { |
591 | setColLin(columns,te->Lines()); | 591 | setColLin(columns,te->Lines()); |
592 | te->update(); | 592 | te->update(); |
593 | } | 593 | } |
594 | } | 594 | } |
595 | 595 | ||
596 | //FIXME: If a child dies during session swap, | 596 | //FIXME: If a child dies during session swap, |
597 | // this routine might be called before | 597 | // this routine might be called before |
598 | // session swap is completed. | 598 | // session swap is completed. |
599 | 599 | ||
600 | void Konsole::doneSession(TESession*, int ) | 600 | void Konsole::doneSession(TESession*, int ) |
601 | { | 601 | { |
602 | TEWidget *te = getTe(); | 602 | TEWidget *te = getTe(); |
603 | if (te != 0) { | 603 | if (te != 0) { |
604 | te->currentSession->setConnect(FALSE); | 604 | te->currentSession->setConnect(FALSE); |
605 | tab->removeTab(te); | 605 | tab->removeTab(te); |
606 | delete te->currentSession; | 606 | delete te->currentSession; |
607 | delete te; | 607 | delete te; |
608 | nsessions--; | 608 | nsessions--; |
609 | } | 609 | } |
610 | 610 | ||
611 | if (nsessions == 0) { | 611 | if (nsessions == 0) { |
612 | close(); | 612 | close(); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | 615 | ||
616 | void Konsole::newSession() { | 616 | void Konsole::newSession() { |
617 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 617 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
618 | TEWidget* te = new TEWidget(tab); | 618 | TEWidget* te = new TEWidget(tab); |
619 | if(nsessions == 0) { //set this the first time only | 619 | Config c("Konsole"); |
620 | Config c("Konsole"); | 620 | c.setGroup("Menubar"); |
621 | c.setGroup("Menubar"); | 621 | te->useBeep=c.readBoolEntry("useBeep",0); |
622 | te->useBeep=c.readBoolEntry("useBeep",0); | ||
623 | } | ||
624 | 622 | ||
625 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 623 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
626 | te->setVTFont(fonts.at(cfont)->getFont()); | 624 | te->setVTFont(fonts.at(cfont)->getFont()); |
627 | tab->addTab(te); | 625 | tab->addTab(te); |
628 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 626 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
629 | te->currentSession = se; | 627 | te->currentSession = se; |
630 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 628 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); |
631 | se->run(); | 629 | se->run(); |
632 | se->setConnect(TRUE); | 630 | se->setConnect(TRUE); |
633 | se->setHistory(b_scroll); | 631 | se->setHistory(b_scroll); |
634 | tab->setCurrentPage(nsessions); | 632 | tab->setCurrentPage(nsessions); |
635 | nsessions++; | 633 | nsessions++; |
636 | doWrap(); | 634 | doWrap(); |
637 | setColor(); | 635 | setColor(); |
638 | } | 636 | } |
639 | } | 637 | } |
640 | 638 | ||
641 | TEWidget* Konsole::getTe() { | 639 | TEWidget* Konsole::getTe() { |
642 | if (nsessions) { | 640 | if (nsessions) { |
643 | return (TEWidget *) tab->currentPage(); | 641 | return (TEWidget *) tab->currentPage(); |
644 | } else { | 642 | } else { |
645 | return 0; | 643 | return 0; |
646 | } | 644 | } |
647 | } | 645 | } |
648 | 646 | ||
649 | void Konsole::switchSession(QWidget* w) { | 647 | void Konsole::switchSession(QWidget* w) { |
650 | TEWidget* te = (TEWidget *) w; | 648 | TEWidget* te = (TEWidget *) w; |
651 | 649 | ||
652 | QFont teFnt = te->getVTFont(); | 650 | QFont teFnt = te->getVTFont(); |
653 | for(uint i = 0; i < fonts.count(); i++) { | 651 | for(uint i = 0; i < fonts.count(); i++) { |
654 | VTFont *fnt = fonts.at(i); | 652 | VTFont *fnt = fonts.at(i); |
655 | bool cf = fnt->getFont() == teFnt; | 653 | bool cf = fnt->getFont() == teFnt; |
656 | fontList->setItemChecked(i, cf); | 654 | fontList->setItemChecked(i, cf); |
657 | if (cf) { | 655 | if (cf) { |
658 | cfont = i; | 656 | cfont = i; |
659 | } | 657 | } |
660 | } | 658 | } |
661 | } | 659 | } |
662 | 660 | ||
663 | void Konsole::colorMenuIsSelected(int iD) { | 661 | void Konsole::colorMenuIsSelected(int iD) { |
664 | fromMenu = TRUE; | 662 | fromMenu = TRUE; |
665 | colorMenuSelected(iD); | 663 | colorMenuSelected(iD); |
666 | } | 664 | } |
667 | 665 | ||
668 | /// ------------------------------- some new stuff by L.J. Potter | 666 | /// ------------------------------- some new stuff by L.J. Potter |
669 | void Konsole::colorMenuSelected(int iD) | 667 | void Konsole::colorMenuSelected(int iD) |
670 | { // this is NOT pretty, elegant or anything else besides functional | 668 | { // this is NOT pretty, elegant or anything else besides functional |
671 | // QString temp; | 669 | // QString temp; |
672 | // qDebug( temp.sprintf("colormenu %d", iD)); | 670 | // qDebug( temp.sprintf("colormenu %d", iD)); |
673 | TEWidget* te = getTe(); | 671 | TEWidget* te = getTe(); |
674 | Config cfg("Konsole"); | 672 | Config cfg("Konsole"); |
675 | cfg.setGroup("Colors"); | 673 | cfg.setGroup("Colors"); |
676 | // QColor foreground; | 674 | // QColor foreground; |
677 | // QColor background; | 675 | // QColor background; |
678 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | 676 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); |
679 | ColorEntry m_table[TABLE_COLORS]; | 677 | ColorEntry m_table[TABLE_COLORS]; |
680 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 678 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
681 | /////////// fore back | 679 | /////////// fore back |
682 | int i; | 680 | int i; |
683 | if(iD==-9) { // default default | 681 | if(iD==-9) { // default default |
684 | for (i = 0; i < TABLE_COLORS; i++) { | 682 | for (i = 0; i < TABLE_COLORS; i++) { |
685 | m_table[i].color = defaultCt[i].color; | 683 | m_table[i].color = defaultCt[i].color; |
686 | if(i==1 || i == 11) | 684 | if(i==1 || i == 11) |
687 | m_table[i].transparent=1; | 685 | m_table[i].transparent=1; |
688 | cfg.writeEntry("Schema","9"); | 686 | cfg.writeEntry("Schema","9"); |
689 | colorMenu->setItemChecked(-9,TRUE); | 687 | colorMenu->setItemChecked(-9,TRUE); |
690 | } | 688 | } |
691 | } else { | 689 | } else { |
692 | if(iD==-6) { // green black | 690 | if(iD==-6) { // green black |
693 | foreground.setRgb(0x18,255,0x18); | 691 | foreground.setRgb(0x18,255,0x18); |
694 | background.setRgb(0x00,0x00,0x00); | 692 | background.setRgb(0x00,0x00,0x00); |
695 | cfg.writeEntry("Schema","6"); | 693 | cfg.writeEntry("Schema","6"); |
696 | colorMenu->setItemChecked(-6,TRUE); | 694 | colorMenu->setItemChecked(-6,TRUE); |
697 | } | 695 | } |
698 | if(iD==-7) { // black white | 696 | if(iD==-7) { // black white |
699 | foreground.setRgb(0x00,0x00,0x00); | 697 | foreground.setRgb(0x00,0x00,0x00); |
700 | background.setRgb(0xFF,0xFF,0xFF); | 698 | background.setRgb(0xFF,0xFF,0xFF); |
701 | cfg.writeEntry("Schema","7"); | 699 | cfg.writeEntry("Schema","7"); |
702 | colorMenu->setItemChecked(-7,TRUE); | 700 | colorMenu->setItemChecked(-7,TRUE); |
703 | } | 701 | } |
704 | if(iD==-8) { // white black | 702 | if(iD==-8) { // white black |
705 | foreground.setRgb(0xFF,0xFF,0xFF); | 703 | foreground.setRgb(0xFF,0xFF,0xFF); |
706 | background.setRgb(0x00,0x00,0x00); | 704 | background.setRgb(0x00,0x00,0x00); |
707 | cfg.writeEntry("Schema","8"); | 705 | cfg.writeEntry("Schema","8"); |
708 | colorMenu->setItemChecked(-8,TRUE); | 706 | colorMenu->setItemChecked(-8,TRUE); |
709 | } | 707 | } |
710 | if(iD==-10) {// Black, Red | 708 | if(iD==-10) {// Black, Red |
711 | foreground.setRgb(0x00,0x00,0x00); | 709 | foreground.setRgb(0x00,0x00,0x00); |
712 | background.setRgb(0xB2,0x18,0x18); | 710 | background.setRgb(0xB2,0x18,0x18); |
713 | cfg.writeEntry("Schema","10"); | 711 | cfg.writeEntry("Schema","10"); |
714 | colorMenu->setItemChecked(-10,TRUE); | 712 | colorMenu->setItemChecked(-10,TRUE); |
715 | } | 713 | } |
716 | if(iD==-11) {// Red, Black | 714 | if(iD==-11) {// Red, Black |
717 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | 715 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 |
718 | background.setRgb(0x00,0x00,0x00); | 716 | background.setRgb(0x00,0x00,0x00); |
719 | cfg.writeEntry("Schema","11"); | 717 | cfg.writeEntry("Schema","11"); |
720 | colorMenu->setItemChecked(-11,TRUE); | 718 | colorMenu->setItemChecked(-11,TRUE); |
721 | } | 719 | } |
722 | if(iD==-12) {// Green, Yellow - is ugly | 720 | if(iD==-12) {// Green, Yellow - is ugly |
723 | // foreground.setRgb(0x18,0xB2,0x18); | 721 | // foreground.setRgb(0x18,0xB2,0x18); |
724 | foreground.setRgb(36,139,10); | 722 | foreground.setRgb(36,139,10); |
725 | // background.setRgb(0xB2,0x68,0x18); | 723 | // background.setRgb(0xB2,0x68,0x18); |
726 | background.setRgb(255,255,0); | 724 | background.setRgb(255,255,0); |
727 | cfg.writeEntry("Schema","12"); | 725 | cfg.writeEntry("Schema","12"); |
728 | colorMenu->setItemChecked(-12,TRUE); | 726 | colorMenu->setItemChecked(-12,TRUE); |
729 | } | 727 | } |
730 | if(iD==-13) {// Blue, Magenta | 728 | if(iD==-13) {// Blue, Magenta |
731 | foreground.setRgb(0x18,0xB2,0xB2); | 729 | foreground.setRgb(0x18,0xB2,0xB2); |
732 | background.setRgb(0x18,0x18,0xB2); | 730 | background.setRgb(0x18,0x18,0xB2); |
733 | cfg.writeEntry("Schema","13"); | 731 | cfg.writeEntry("Schema","13"); |
734 | colorMenu->setItemChecked(-13,TRUE); | 732 | colorMenu->setItemChecked(-13,TRUE); |
735 | } | 733 | } |
736 | if(iD==-14) {// Magenta, Blue | 734 | if(iD==-14) {// Magenta, Blue |
737 | foreground.setRgb(0x18,0x18,0xB2); | 735 | foreground.setRgb(0x18,0x18,0xB2); |
738 | background.setRgb(0x18,0xB2,0xB2); | 736 | background.setRgb(0x18,0xB2,0xB2); |
739 | cfg.writeEntry("Schema","14"); | 737 | cfg.writeEntry("Schema","14"); |
740 | colorMenu->setItemChecked(-14,TRUE); | 738 | colorMenu->setItemChecked(-14,TRUE); |
741 | } | 739 | } |
742 | if(iD==-15) {// Cyan, White | 740 | if(iD==-15) {// Cyan, White |
743 | foreground.setRgb(0x18,0xB2,0xB2); | 741 | foreground.setRgb(0x18,0xB2,0xB2); |
744 | background.setRgb(0xFF,0xFF,0xFF); | 742 | background.setRgb(0xFF,0xFF,0xFF); |
745 | cfg.writeEntry("Schema","15"); | 743 | cfg.writeEntry("Schema","15"); |
746 | colorMenu->setItemChecked(-15,TRUE); | 744 | colorMenu->setItemChecked(-15,TRUE); |
747 | } | 745 | } |
748 | if(iD==-16) {// White, Cyan | 746 | if(iD==-16) {// White, Cyan |
749 | background.setRgb(0x18,0xB2,0xB2); | 747 | background.setRgb(0x18,0xB2,0xB2); |
750 | foreground.setRgb(0xFF,0xFF,0xFF); | 748 | foreground.setRgb(0xFF,0xFF,0xFF); |
751 | cfg.writeEntry("Schema","16"); | 749 | cfg.writeEntry("Schema","16"); |
752 | colorMenu->setItemChecked(-16,TRUE); | 750 | colorMenu->setItemChecked(-16,TRUE); |
753 | } | 751 | } |
754 | if(iD==-17) {// Black, Blue | 752 | if(iD==-17) {// Black, Blue |
755 | background.setRgb(0x00,0x00,0x00); | 753 | background.setRgb(0x00,0x00,0x00); |
756 | foreground.setRgb(0x18,0xB2,0xB2); | 754 | foreground.setRgb(0x18,0xB2,0xB2); |
757 | cfg.writeEntry("Schema","17"); | 755 | cfg.writeEntry("Schema","17"); |
758 | colorMenu->setItemChecked(-17,TRUE); | 756 | colorMenu->setItemChecked(-17,TRUE); |
759 | } | 757 | } |
760 | if(iD==-18) {// Black, Gold | 758 | if(iD==-18) {// Black, Gold |
761 | background.setRgb(0x00,0x00,0x00); | 759 | background.setRgb(0x00,0x00,0x00); |
762 | foreground.setRgb(255,215,0); | 760 | foreground.setRgb(255,215,0); |
763 | cfg.writeEntry("Schema","18"); | 761 | cfg.writeEntry("Schema","18"); |
764 | colorMenu->setItemChecked(-18,TRUE); | 762 | colorMenu->setItemChecked(-18,TRUE); |
765 | } | 763 | } |
766 | #ifdef QT_QWS_OPIE | 764 | #ifdef QT_QWS_OPIE |
767 | if(iD==-19) { | 765 | if(iD==-19) { |
768 | // Custom | 766 | // Custom |
769 | qDebug("do custom"); | 767 | qDebug("do custom"); |
770 | if(fromMenu) { | 768 | if(fromMenu) { |
771 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); | 769 | ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(Qt::black, this, "foreground color"); |
772 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 770 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
773 | SLOT(changeForegroundColor(const QColor&))); | 771 | SLOT(changeForegroundColor(const QColor&))); |
774 | penColorPopupMenu->exec(); | 772 | penColorPopupMenu->exec(); |
775 | } | 773 | } |
776 | cfg.writeEntry("Schema","19"); | 774 | cfg.writeEntry("Schema","19"); |
777 | if(!fromMenu) { | 775 | if(!fromMenu) { |
778 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 776 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
779 | background.setNamedColor(cfg.readEntry("background","")); | 777 | background.setNamedColor(cfg.readEntry("background","")); |
780 | } | 778 | } |
781 | fromMenu=FALSE; | 779 | fromMenu=FALSE; |
782 | colorMenu->setItemChecked(-19,TRUE); | 780 | colorMenu->setItemChecked(-19,TRUE); |
783 | } | 781 | } |
784 | #endif | 782 | #endif |
785 | for (i = 0; i < TABLE_COLORS; i++) { | 783 | for (i = 0; i < TABLE_COLORS; i++) { |
786 | if(i==0 || i == 10) { | 784 | if(i==0 || i == 10) { |
787 | m_table[i].color = foreground; | 785 | m_table[i].color = foreground; |
788 | } | 786 | } |
789 | else if(i==1 || i == 11) { | 787 | else if(i==1 || i == 11) { |
790 | m_table[i].color = background; m_table[i].transparent=0; | 788 | m_table[i].color = background; m_table[i].transparent=0; |
791 | } | 789 | } |
792 | else | 790 | else |
793 | m_table[i].color = defaultCt[i].color; | 791 | m_table[i].color = defaultCt[i].color; |
794 | } | 792 | } |
795 | } | 793 | } |
796 | lastSelectedMenu = iD; | 794 | lastSelectedMenu = iD; |
797 | te->setColorTable(m_table); | 795 | te->setColorTable(m_table); |
798 | update(); | 796 | update(); |
799 | 797 | ||
800 | } | 798 | } |
801 | 799 | ||
802 | void Konsole::configMenuSelected(int iD) | 800 | void Konsole::configMenuSelected(int iD) |
803 | { | 801 | { |
804 | // QString temp; | 802 | // QString temp; |
805 | // qDebug( temp.sprintf("configmenu %d",iD)); | 803 | // qDebug( temp.sprintf("configmenu %d",iD)); |
806 | TEWidget* te = getTe(); | 804 | TEWidget* te = getTe(); |
807 | Config cfg("Konsole"); | 805 | Config cfg("Konsole"); |
808 | cfg.setGroup("Menubar"); | 806 | cfg.setGroup("Menubar"); |
809 | int i,j; | 807 | int i,j; |
810 | #ifdef QT_QWS_OPIE | 808 | #ifdef QT_QWS_OPIE |
811 | i=-29;j=-30; | 809 | i=-29;j=-30; |
812 | #else | 810 | #else |
813 | i=-28;j=-29; | 811 | i=-28;j=-29; |
814 | #endif | 812 | #endif |
815 | 813 | ||
816 | if(iD == -4) { | 814 | if(iD == -4) { |
817 | cfg.setGroup("Tabs"); | 815 | cfg.setGroup("Tabs"); |
818 | QString tmp=cfg.readEntry("Position","Bottom"); | 816 | QString tmp=cfg.readEntry("Position","Bottom"); |
819 | 817 | ||
820 | if(tmp=="Top") { | 818 | if(tmp=="Top") { |
821 | tab->setTabPosition(QTabWidget::Bottom); | 819 | tab->setTabPosition(QTabWidget::Bottom); |
822 | configMenu->changeItem( iD, tr("Tabs on Top")); | 820 | configMenu->changeItem( iD, tr("Tabs on Top")); |
823 | cfg.writeEntry("Position","Bottom"); | 821 | cfg.writeEntry("Position","Bottom"); |
824 | } else { | 822 | } else { |
825 | tab->setTabPosition(QTabWidget::Top); | 823 | tab->setTabPosition(QTabWidget::Top); |
826 | configMenu->changeItem( iD, tr("Tabs on Bottom")); | 824 | configMenu->changeItem( iD, tr("Tabs on Bottom")); |
827 | cfg.writeEntry("Position","Top"); | 825 | cfg.writeEntry("Position","Top"); |
828 | } | 826 | } |
829 | } | 827 | } |
830 | if(iD == i) { | 828 | if(iD == i) { |
831 | cfg.setGroup("ScrollBar"); | 829 | cfg.setGroup("ScrollBar"); |
832 | bool b=cfg.readBoolEntry("HorzScroll",0); | 830 | bool b=cfg.readBoolEntry("HorzScroll",0); |
833 | b=!b; | 831 | b=!b; |
834 | cfg.writeEntry("HorzScroll", b ); | 832 | cfg.writeEntry("HorzScroll", b ); |
835 | cfg.write(); | 833 | cfg.write(); |
836 | doWrap(); | 834 | doWrap(); |
837 | if(cfg.readNumEntry("Position",2) == 0) { | 835 | if(cfg.readNumEntry("Position",2) == 0) { |
838 | te->setScrollbarLocation(1); | 836 | te->setScrollbarLocation(1); |
839 | } else { | 837 | } else { |
840 | te->setScrollbarLocation(0); | 838 | te->setScrollbarLocation(0); |
841 | } | 839 | } |
842 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 840 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
843 | } | 841 | } |
844 | if(iD == j) { | 842 | if(iD == j) { |
845 | cfg.setGroup("Menubar"); | 843 | cfg.setGroup("Menubar"); |
846 | bool b=cfg.readBoolEntry("useBeep",0); | 844 | bool b=cfg.readBoolEntry("useBeep",0); |
847 | b=!b; | 845 | b=!b; |
848 | cfg.writeEntry("useBeep", b ); | 846 | cfg.writeEntry("useBeep", b ); |
849 | cfg.write(); | 847 | cfg.write(); |
850 | configMenu->setItemChecked(j,b); | 848 | configMenu->setItemChecked(j,b); |
851 | te->useBeep=b; | 849 | te->useBeep=b; |
852 | } | 850 | } |
853 | } | 851 | } |
854 | 852 | ||
855 | void Konsole::changeCommand(const QString &text, int c) | 853 | void Konsole::changeCommand(const QString &text, int c) |
856 | { | 854 | { |
857 | Config cfg("Konsole"); | 855 | Config cfg("Konsole"); |
858 | cfg.setGroup("Commands"); | 856 | cfg.setGroup("Commands"); |
859 | if(commonCmds[c] != text) { | 857 | if(commonCmds[c] != text) { |
860 | cfg.writeEntry(QString::number(c),text); | 858 | cfg.writeEntry(QString::number(c),text); |
861 | commonCombo->clearEdit(); | 859 | commonCombo->clearEdit(); |
862 | commonCombo->setCurrentItem(c); | 860 | commonCombo->setCurrentItem(c); |
863 | } | 861 | } |
864 | } | 862 | } |
865 | 863 | ||
866 | void Konsole::setColor() | 864 | void Konsole::setColor() |
867 | { | 865 | { |
868 | Config cfg("Konsole"); | 866 | Config cfg("Konsole"); |
869 | cfg.setGroup("Colors"); | 867 | cfg.setGroup("Colors"); |
870 | int scheme = cfg.readNumEntry("Schema",1); | 868 | int scheme = cfg.readNumEntry("Schema",1); |
871 | if(scheme != 1) colorMenuSelected( -scheme); | 869 | if(scheme != 1) colorMenuSelected( -scheme); |
872 | } | 870 | } |
873 | 871 | ||
874 | void Konsole::scrollMenuSelected(int index) | 872 | void Konsole::scrollMenuSelected(int index) |
875 | { | 873 | { |
876 | qDebug( "scrollbar menu %d",index); | 874 | qDebug( "scrollbar menu %d",index); |
877 | TEWidget* te = getTe(); | 875 | TEWidget* te = getTe(); |
878 | Config cfg("Konsole"); | 876 | Config cfg("Konsole"); |
879 | cfg.setGroup("ScrollBar"); | 877 | cfg.setGroup("ScrollBar"); |
880 | int i,j,k; | 878 | int i,j,k; |
881 | #ifdef QT_QWS_OPIE | 879 | #ifdef QT_QWS_OPIE |
882 | i=-25;j=-26;k=-27; | 880 | i=-25;j=-26;k=-27; |
883 | #else | 881 | #else |
884 | i=-24;j=-25;k=-26; | 882 | i=-24;j=-25;k=-26; |
885 | #endif | 883 | #endif |
886 | if(index == i) { | 884 | if(index == i) { |
887 | 885 | ||
888 | te->setScrollbarLocation(0); | 886 | te->setScrollbarLocation(0); |
889 | cfg.writeEntry("Position",0); | 887 | cfg.writeEntry("Position",0); |
890 | } else if(index == j) { | 888 | } else if(index == j) { |
891 | 889 | ||
892 | te->setScrollbarLocation(1); | 890 | te->setScrollbarLocation(1); |
893 | cfg.writeEntry("Position",1); | 891 | cfg.writeEntry("Position",1); |
894 | } else if(index == k) { | 892 | } else if(index == k) { |
895 | 893 | ||
896 | te->setScrollbarLocation(2); | 894 | te->setScrollbarLocation(2); |
897 | cfg.writeEntry("Position",2); | 895 | cfg.writeEntry("Position",2); |
898 | } | 896 | } |
899 | 897 | ||
900 | // case -29: { | 898 | // case -29: { |
901 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 899 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
902 | // cfg.writeEntry("HorzScroll", !b ); | 900 | // cfg.writeEntry("HorzScroll", !b ); |
903 | // cfg.write(); | 901 | // cfg.write(); |
904 | // if(cfg.readNumEntry("Position",2) == 0) { | 902 | // if(cfg.readNumEntry("Position",2) == 0) { |
905 | // te->setScrollbarLocation(1); | 903 | // te->setScrollbarLocation(1); |
906 | // te->setWrapAt(0); | 904 | // te->setWrapAt(0); |
907 | // } else { | 905 | // } else { |
908 | // te->setScrollbarLocation(0); | 906 | // te->setScrollbarLocation(0); |
909 | // te->setWrapAt(120); | 907 | // te->setWrapAt(120); |
910 | // } | 908 | // } |
911 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 909 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
912 | // } | 910 | // } |
913 | // break; | 911 | // break; |
914 | } | 912 | } |
915 | 913 | ||
916 | void Konsole::editCommandListMenuSelected(int iD) | 914 | void Konsole::editCommandListMenuSelected(int iD) |
917 | { | 915 | { |
918 | // QString temp; | 916 | // QString temp; |
919 | // qDebug( temp.sprintf("edit command list %d",iD)); | 917 | // qDebug( temp.sprintf("edit command list %d",iD)); |
920 | TEWidget* te = getTe(); | 918 | TEWidget* te = getTe(); |
921 | Config cfg("Konsole"); | 919 | Config cfg("Konsole"); |
922 | cfg.setGroup("Menubar"); | 920 | cfg.setGroup("Menubar"); |
923 | if( iD == -3) { | 921 | if( iD == -3) { |
924 | if(!secondToolBar->isHidden()) { | 922 | if(!secondToolBar->isHidden()) { |
925 | secondToolBar->hide(); | 923 | secondToolBar->hide(); |
926 | configMenu->changeItem( iD,tr( "Show Command List" )); | 924 | configMenu->changeItem( iD,tr( "Show Command List" )); |
927 | cfg.writeEntry("Hidden","TRUE"); | 925 | cfg.writeEntry("Hidden","TRUE"); |
928 | configMenu->setItemEnabled(-23 ,FALSE); | 926 | configMenu->setItemEnabled(-23 ,FALSE); |
929 | } else { | 927 | } else { |
930 | secondToolBar->show(); | 928 | secondToolBar->show(); |
931 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 929 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
932 | cfg.writeEntry("Hidden","FALSE"); | 930 | cfg.writeEntry("Hidden","FALSE"); |
933 | configMenu->setItemEnabled(-23 ,TRUE); | 931 | configMenu->setItemEnabled(-23 ,TRUE); |
934 | 932 | ||
935 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 933 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { |
936 | configMenu->setItemChecked(-23,TRUE); | 934 | configMenu->setItemChecked(-23,TRUE); |
937 | commonCombo->setEditable( TRUE ); | 935 | commonCombo->setEditable( TRUE ); |
938 | } else { | 936 | } else { |
939 | configMenu->setItemChecked(-23,FALSE); | 937 | configMenu->setItemChecked(-23,FALSE); |
940 | commonCombo->setEditable( FALSE ); | 938 | commonCombo->setEditable( FALSE ); |
941 | } | 939 | } |
942 | } | 940 | } |
943 | } | 941 | } |
944 | if( iD == -23) { | 942 | if( iD == -23) { |
945 | cfg.setGroup("Commands"); | 943 | cfg.setGroup("Commands"); |
946 | // qDebug("enableCommandEdit"); | 944 | // qDebug("enableCommandEdit"); |
947 | if( !configMenu->isItemChecked(iD) ) { | 945 | if( !configMenu->isItemChecked(iD) ) { |
948 | commonCombo->setEditable( TRUE ); | 946 | commonCombo->setEditable( TRUE ); |
949 | configMenu->setItemChecked(iD,TRUE); | 947 | configMenu->setItemChecked(iD,TRUE); |
950 | commonCombo->setCurrentItem(0); | 948 | commonCombo->setCurrentItem(0); |
951 | cfg.writeEntry("EditEnabled","TRUE"); | 949 | cfg.writeEntry("EditEnabled","TRUE"); |
952 | } else { | 950 | } else { |
953 | commonCombo->setEditable( FALSE ); | 951 | commonCombo->setEditable( FALSE ); |
954 | configMenu->setItemChecked(iD,FALSE); | 952 | configMenu->setItemChecked(iD,FALSE); |
955 | cfg.writeEntry("EditEnabled","FALSE"); | 953 | cfg.writeEntry("EditEnabled","FALSE"); |
956 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 954 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
957 | te->setFocus(); | 955 | te->setFocus(); |
958 | } | 956 | } |
959 | } | 957 | } |
960 | if(iD == -24) { | 958 | if(iD == -24) { |
961 | // "edit commands" | 959 | // "edit commands" |
962 | CommandEditDialog *m = new CommandEditDialog(this); | 960 | CommandEditDialog *m = new CommandEditDialog(this); |
963 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 961 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
964 | m->showMaximized(); | 962 | m->showMaximized(); |
965 | } | 963 | } |
966 | 964 | ||
967 | } | 965 | } |
968 | 966 | ||
969 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 967 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
970 | void Konsole::setDocument( const QString &cmd) { | 968 | void Konsole::setDocument( const QString &cmd) { |
971 | newSession(); | 969 | newSession(); |
972 | TEWidget* te = getTe(); | 970 | TEWidget* te = getTe(); |
973 | if(cmd.find("-e", 0, TRUE) != -1) { | 971 | if(cmd.find("-e", 0, TRUE) != -1) { |
974 | QString cmd2; | 972 | QString cmd2; |
975 | cmd2=cmd.right(cmd.length()-3)+" &"; | 973 | cmd2=cmd.right(cmd.length()-3)+" &"; |
976 | system(cmd2.latin1()); | 974 | system(cmd2.latin1()); |
977 | if(startUp <= 1 && nsessions < 2) { | 975 | if(startUp <= 1 && nsessions < 2) { |
978 | doneSession(getTe()->currentSession, 0); | 976 | doneSession(getTe()->currentSession, 0); |
979 | exit(0); | 977 | exit(0); |
980 | } else | 978 | } else |
981 | doneSession(getTe()->currentSession, 0); | 979 | doneSession(getTe()->currentSession, 0); |
982 | } else { | 980 | } else { |
983 | if (te != 0) { | 981 | if (te != 0) { |
984 | te->emitText(cmd+"\r"); | 982 | te->emitText(cmd+"\r"); |
985 | } | 983 | } |
986 | } | 984 | } |
987 | startUp++; | 985 | startUp++; |
988 | } | 986 | } |
989 | 987 | ||
990 | void Konsole::parseCommandLine() { | 988 | void Konsole::parseCommandLine() { |
991 | QString cmd; | 989 | QString cmd; |
992 | // newSession(); | 990 | // newSession(); |
993 | for (int i=1;i< qApp->argc();i++) { | 991 | for (int i=1;i< qApp->argc();i++) { |
994 | if( QString(qApp->argv()[i]) == "-e") { | 992 | if( QString(qApp->argv()[i]) == "-e") { |
995 | i++; | 993 | i++; |
996 | for ( int j=i;j< qApp->argc();j++) { | 994 | for ( int j=i;j< qApp->argc();j++) { |
997 | cmd+=QString(qApp->argv()[j])+" "; | 995 | cmd+=QString(qApp->argv()[j])+" "; |
998 | } | 996 | } |
999 | cmd.stripWhiteSpace(); | 997 | cmd.stripWhiteSpace(); |
1000 | system(cmd.latin1()); | 998 | system(cmd.latin1()); |
1001 | exit(0);//close(); | 999 | exit(0);//close(); |
1002 | } // end -e switch | 1000 | } // end -e switch |
1003 | } | 1001 | } |
1004 | startUp++; | 1002 | startUp++; |
1005 | } | 1003 | } |
1006 | 1004 | ||
1007 | void Konsole::changeForegroundColor(const QColor &color) { | 1005 | void Konsole::changeForegroundColor(const QColor &color) { |
1008 | Config cfg("Konsole"); | 1006 | Config cfg("Konsole"); |
1009 | cfg.setGroup("Colors"); | 1007 | cfg.setGroup("Colors"); |
1010 | int r, g, b; | 1008 | int r, g, b; |
1011 | color.rgb(&r,&g,&b); | 1009 | color.rgb(&r,&g,&b); |
1012 | foreground.setRgb(r,g,b); | 1010 | foreground.setRgb(r,g,b); |
1013 | 1011 | ||
1014 | cfg.writeEntry("foreground",color.name()); | 1012 | cfg.writeEntry("foreground",color.name()); |
1015 | qDebug("foreground "+color.name()); | 1013 | qDebug("foreground "+color.name()); |
1016 | cfg.write(); | 1014 | cfg.write(); |
1017 | 1015 | ||
1018 | qDebug("do other dialog"); | 1016 | qDebug("do other dialog"); |
1019 | #ifdef QT_QWS_OPIE | 1017 | #ifdef QT_QWS_OPIE |
1020 | 1018 | ||
1021 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); | 1019 | ColorPopupMenu* penColorPopupMenu2 = new ColorPopupMenu(Qt::black, this,"background color"); |
1022 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1020 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1023 | SLOT(changeBackgroundColor(const QColor&))); | 1021 | SLOT(changeBackgroundColor(const QColor&))); |
1024 | penColorPopupMenu2->exec(); | 1022 | penColorPopupMenu2->exec(); |
1025 | #endif | 1023 | #endif |
1026 | } | 1024 | } |
1027 | 1025 | ||
1028 | void Konsole::changeBackgroundColor(const QColor &color) { | 1026 | void Konsole::changeBackgroundColor(const QColor &color) { |
1029 | 1027 | ||
1030 | qDebug("Change background"); | 1028 | qDebug("Change background"); |
1031 | Config cfg("Konsole"); | 1029 | Config cfg("Konsole"); |
1032 | cfg.setGroup("Colors"); | 1030 | cfg.setGroup("Colors"); |
1033 | int r, g, b; | 1031 | int r, g, b; |
1034 | color.rgb(&r,&g,&b); | 1032 | color.rgb(&r,&g,&b); |
1035 | background.setRgb(r,g,b); | 1033 | background.setRgb(r,g,b); |
1036 | cfg.writeEntry("background",color.name()); | 1034 | cfg.writeEntry("background",color.name()); |
1037 | qDebug("background "+color.name()); | 1035 | qDebug("background "+color.name()); |
1038 | cfg.write(); | 1036 | cfg.write(); |
1039 | } | 1037 | } |
1040 | 1038 | ||
1041 | void Konsole::doWrap() { | 1039 | void Konsole::doWrap() { |
1042 | int i; | 1040 | int i; |
1043 | #ifdef QT_QWS_OPIE | 1041 | #ifdef QT_QWS_OPIE |
1044 | i=-29; | 1042 | i=-29; |
1045 | #else | 1043 | #else |
1046 | i=-28; | 1044 | i=-28; |
1047 | #endif | 1045 | #endif |
1048 | 1046 | ||
1049 | Config cfg("Konsole"); | 1047 | Config cfg("Konsole"); |
1050 | cfg.setGroup("ScrollBar"); | 1048 | cfg.setGroup("ScrollBar"); |
1051 | TEWidget* te = getTe(); | 1049 | TEWidget* te = getTe(); |
1052 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1050 | if( !cfg.readBoolEntry("HorzScroll",0)) { |
1053 | te->setWrapAt(0); | 1051 | te->setWrapAt(0); |
1054 | configMenu->setItemChecked( i,TRUE); | 1052 | configMenu->setItemChecked( i,TRUE); |
1055 | } else { | 1053 | } else { |
1056 | // te->setWrapAt(90); | 1054 | // te->setWrapAt(90); |
1057 | te->setWrapAt(120); | 1055 | te->setWrapAt(120); |
1058 | configMenu->setItemChecked( i,FALSE); | 1056 | configMenu->setItemChecked( i,FALSE); |
1059 | } | 1057 | } |
1060 | } | 1058 | } |