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