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