author | drw <drw> | 2005-04-15 17:51:00 (UTC) |
---|---|---|
committer | drw <drw> | 2005-04-15 17:51:00 (UTC) |
commit | ba9d5ecee89aadb135a03c173878e315de784be3 (patch) (unidiff) | |
tree | 176d774bebfaa1d016a56fa8c00be79a2ea19fa5 | |
parent | 86b1feed1ab2e47a082d974e1fcc513c59a74469 (diff) | |
download | opie-ba9d5ecee89aadb135a03c173878e315de784be3.zip opie-ba9d5ecee89aadb135a03c173878e315de784be3.tar.gz opie-ba9d5ecee89aadb135a03c173878e315de784be3.tar.bz2 |
Resource -> OResource
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 23 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 37 |
2 files changed, 39 insertions, 21 deletions
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index 697bf72..1e08767 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -1,191 +1,200 @@ | |||
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 | |||
6 | #include <opie2/oresource.h> | ||
7 | |||
5 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
6 | #include <qpe/resource.h> | 9 | |
10 | #include <qapplication.h> | ||
7 | #include <qtoolbutton.h> | 11 | #include <qtoolbutton.h> |
8 | #include <qlineedit.h> | 12 | #include <qlineedit.h> |
9 | #include <qheader.h> | 13 | #include <qheader.h> |
10 | #include <qlabel.h> | 14 | #include <qlabel.h> |
11 | #include "smallcommandeditdialogbase.h" | 15 | #include "smallcommandeditdialogbase.h" |
12 | 16 | ||
13 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) | 17 | CommandEditDialog::CommandEditDialog(QWidget *parent, const char* name, WFlags fl ) |
14 | : CommandEditDialogBase(parent, name, TRUE, fl) | 18 | : CommandEditDialogBase(parent, name, TRUE, fl) |
15 | 19 | ||
16 | { | 20 | { |
17 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); | 21 | m_SuggestedCommandList->addColumn( tr("Command Selection") ); |
18 | m_SuggestedCommandList->header()->hide(); | 22 | m_SuggestedCommandList->header()->hide(); |
19 | m_SuggestedCommandList->setSorting(-1,FALSE); | 23 | m_SuggestedCommandList->setSorting(-1,FALSE); |
20 | m_SuggestedCommandList->clearSelection(); | 24 | m_SuggestedCommandList->clearSelection(); |
21 | m_SuggestedCommandList->setSorting(0,TRUE); | 25 | m_SuggestedCommandList->setSorting(0,TRUE); |
22 | QListViewItem *item; | 26 | QListViewItem *item; |
23 | item = new QListViewItem( m_SuggestedCommandList,"export "); | 27 | item = new QListViewItem( m_SuggestedCommandList,"export "); |
24 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); | 28 | item = new QListViewItem( m_SuggestedCommandList,"ifconfig "); |
25 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); | 29 | item = new QListViewItem( m_SuggestedCommandList,"ipkg "); |
26 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); | 30 | item = new QListViewItem( m_SuggestedCommandList,"gzip "); |
27 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); | 31 | item = new QListViewItem( m_SuggestedCommandList,"gunzip "); |
28 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); | 32 | item = new QListViewItem( m_SuggestedCommandList,"chgrp "); |
29 | item = new QListViewItem( m_SuggestedCommandList,"chown "); | 33 | item = new QListViewItem( m_SuggestedCommandList,"chown "); |
30 | item = new QListViewItem( m_SuggestedCommandList,"date "); | 34 | item = new QListViewItem( m_SuggestedCommandList,"date "); |
31 | item = new QListViewItem( m_SuggestedCommandList,"dd "); | 35 | item = new QListViewItem( m_SuggestedCommandList,"dd "); |
32 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); | 36 | item = new QListViewItem( m_SuggestedCommandList,"dmesg "); |
33 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); | 37 | item = new QListViewItem( m_SuggestedCommandList,"fuser "); |
34 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); | 38 | item = new QListViewItem( m_SuggestedCommandList,"hostname "); |
35 | item = new QListViewItem( m_SuggestedCommandList,"kill "); | 39 | item = new QListViewItem( m_SuggestedCommandList,"kill "); |
36 | item = new QListViewItem( m_SuggestedCommandList,"killall "); | 40 | item = new QListViewItem( m_SuggestedCommandList,"killall "); |
37 | item = new QListViewItem( m_SuggestedCommandList,"ln "); | 41 | item = new QListViewItem( m_SuggestedCommandList,"ln "); |
38 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); | 42 | item = new QListViewItem( m_SuggestedCommandList,"ln -s "); |
39 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); | 43 | item = new QListViewItem( m_SuggestedCommandList,"lsmod"); |
40 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); | 44 | item = new QListViewItem( m_SuggestedCommandList,"depmod -a"); |
41 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); | 45 | item = new QListViewItem( m_SuggestedCommandList,"modprobe "); |
42 | item = new QListViewItem( m_SuggestedCommandList,"mount "); | 46 | item = new QListViewItem( m_SuggestedCommandList,"mount "); |
43 | item = new QListViewItem( m_SuggestedCommandList,"more "); | 47 | item = new QListViewItem( m_SuggestedCommandList,"more "); |
44 | item = new QListViewItem( m_SuggestedCommandList,"sort "); | 48 | item = new QListViewItem( m_SuggestedCommandList,"sort "); |
45 | item = new QListViewItem( m_SuggestedCommandList,"touch "); | 49 | item = new QListViewItem( m_SuggestedCommandList,"touch "); |
46 | item = new QListViewItem( m_SuggestedCommandList,"umount "); | 50 | item = new QListViewItem( m_SuggestedCommandList,"umount "); |
47 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); | 51 | item = new QListViewItem( m_SuggestedCommandList,"mknod "); |
48 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); | 52 | item = new QListViewItem( m_SuggestedCommandList,"netstat "); |
49 | item = new QListViewItem( m_SuggestedCommandList,"route "); | 53 | item = new QListViewItem( m_SuggestedCommandList,"route "); |
50 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); | 54 | item = new QListViewItem( m_SuggestedCommandList,"cardctl eject "); |
51 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); | 55 | m_SuggestedCommandList->setSelected(m_SuggestedCommandList->firstChild(),TRUE); |
52 | m_SuggestedCommandList->sort(); | 56 | m_SuggestedCommandList->sort(); |
53 | 57 | ||
54 | connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); | 58 | connect( m_SuggestedCommandList, SIGNAL( clicked(QListViewItem*) ), m_PlayListSelection, SLOT( addToSelection(QListViewItem*) ) ); |
55 | 59 | ||
56 | 60 | bool bigPixmaps = qApp->desktop()->size().width()>330; | |
57 | 61 | ||
58 | ToolButton1->setTextLabel("new"); | 62 | ToolButton1->setTextLabel("new"); |
59 | ToolButton1->setPixmap(Resource::loadPixmap("new")); | 63 | ToolButton1->setUsesBigPixmap( bigPixmaps ); |
64 | ToolButton1->setPixmap( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ) ); | ||
60 | ToolButton1->setAutoRaise(TRUE); | 65 | ToolButton1->setAutoRaise(TRUE); |
61 | ToolButton1->setFocusPolicy(QWidget::NoFocus); | 66 | ToolButton1->setFocusPolicy(QWidget::NoFocus); |
62 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); | 67 | connect(ToolButton1,SIGNAL(clicked()),this,SLOT(showAddDialog())); |
63 | 68 | ||
64 | ToolButton2->setTextLabel("edit"); | 69 | ToolButton2->setTextLabel("edit"); |
65 | ToolButton2->setPixmap(Resource::loadPixmap("edit")); | 70 | ToolButton2->setUsesBigPixmap( bigPixmaps ); |
71 | ToolButton2->setPixmap( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ) ); | ||
66 | ToolButton2->setAutoRaise(TRUE); | 72 | ToolButton2->setAutoRaise(TRUE); |
67 | ToolButton2->setFocusPolicy(QWidget::NoFocus); | 73 | ToolButton2->setFocusPolicy(QWidget::NoFocus); |
68 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); | 74 | connect(ToolButton2,SIGNAL(clicked()),this,SLOT(showEditDialog())); |
69 | 75 | ||
70 | ToolButton3->setTextLabel("delete"); | 76 | ToolButton3->setTextLabel("delete"); |
71 | ToolButton3->setPixmap(Resource::loadPixmap("editdelete")); | 77 | ToolButton3->setUsesBigPixmap( bigPixmaps ); |
78 | ToolButton3->setPixmap( Opie::Core::OResource::loadPixmap( "editdelete", Opie::Core::OResource::SmallIcon ) ); | ||
72 | ToolButton3->setAutoRaise(TRUE); | 79 | ToolButton3->setAutoRaise(TRUE); |
73 | ToolButton3->setFocusPolicy(QWidget::NoFocus); | 80 | ToolButton3->setFocusPolicy(QWidget::NoFocus); |
74 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); | 81 | connect(ToolButton3,SIGNAL(clicked()),m_PlayListSelection,SLOT(removeSelected())); |
75 | 82 | ||
76 | ToolButton4->setTextLabel("up"); | 83 | ToolButton4->setTextLabel("up"); |
77 | ToolButton4->setPixmap(Resource::loadPixmap("up")); | 84 | ToolButton4->setUsesBigPixmap( bigPixmaps ); |
85 | ToolButton4->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); | ||
78 | ToolButton4->setAutoRaise(TRUE); | 86 | ToolButton4->setAutoRaise(TRUE); |
79 | ToolButton4->setFocusPolicy(QWidget::NoFocus); | 87 | ToolButton4->setFocusPolicy(QWidget::NoFocus); |
80 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); | 88 | connect(ToolButton4,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedUp())); |
81 | 89 | ||
82 | ToolButton5->setTextLabel("down"); | 90 | ToolButton5->setTextLabel("down"); |
83 | ToolButton5->setPixmap(Resource::loadPixmap("down")); | 91 | ToolButton5->setUsesBigPixmap( bigPixmaps ); |
92 | ToolButton5->setPixmap( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) ); | ||
84 | ToolButton5->setAutoRaise(TRUE); | 93 | ToolButton5->setAutoRaise(TRUE); |
85 | ToolButton5->setFocusPolicy(QWidget::NoFocus); | 94 | ToolButton5->setFocusPolicy(QWidget::NoFocus); |
86 | 95 | ||
87 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); | 96 | connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown())); |
88 | 97 | ||
89 | 98 | ||
90 | 99 | ||
91 | 100 | ||
92 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 101 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
93 | if ( current ) | 102 | if ( current ) |
94 | item->moveItem( current ); | 103 | item->moveItem( current ); |
95 | m_SuggestedCommandList->setSelected( item, TRUE ); | 104 | m_SuggestedCommandList->setSelected( item, TRUE ); |
96 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 105 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
97 | Config cfg( "Konsole" ); | 106 | Config cfg( "Konsole" ); |
98 | cfg.setGroup("Commands"); | 107 | cfg.setGroup("Commands"); |
99 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 108 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
100 | for (int i = 0; i < 100; i++) { | 109 | for (int i = 0; i < 100; i++) { |
101 | QString tmp; | 110 | QString tmp; |
102 | tmp = cfg.readEntry( QString::number(i),""); | 111 | tmp = cfg.readEntry( QString::number(i),""); |
103 | if (!tmp.isEmpty()) | 112 | if (!tmp.isEmpty()) |
104 | m_PlayListSelection->addStringToSelection(tmp); | 113 | m_PlayListSelection->addStringToSelection(tmp); |
105 | } | 114 | } |
106 | } else { | 115 | } else { |
107 | 116 | ||
108 | m_PlayListSelection->addStringToSelection("ls "); | 117 | m_PlayListSelection->addStringToSelection("ls "); |
109 | m_PlayListSelection->addStringToSelection("cardctl eject"); | 118 | m_PlayListSelection->addStringToSelection("cardctl eject"); |
110 | m_PlayListSelection->addStringToSelection("cat "); | 119 | m_PlayListSelection->addStringToSelection("cat "); |
111 | m_PlayListSelection->addStringToSelection("cd "); | 120 | m_PlayListSelection->addStringToSelection("cd "); |
112 | m_PlayListSelection->addStringToSelection("chmod "); | 121 | m_PlayListSelection->addStringToSelection("chmod "); |
113 | m_PlayListSelection->addStringToSelection("cp "); | 122 | m_PlayListSelection->addStringToSelection("cp "); |
114 | m_PlayListSelection->addStringToSelection("dc "); | 123 | m_PlayListSelection->addStringToSelection("dc "); |
115 | m_PlayListSelection->addStringToSelection("df "); | 124 | m_PlayListSelection->addStringToSelection("df "); |
116 | m_PlayListSelection->addStringToSelection("dmesg"); | 125 | m_PlayListSelection->addStringToSelection("dmesg"); |
117 | m_PlayListSelection->addStringToSelection("echo "); | 126 | m_PlayListSelection->addStringToSelection("echo "); |
118 | m_PlayListSelection->addStringToSelection("env"); | 127 | m_PlayListSelection->addStringToSelection("env"); |
119 | m_PlayListSelection->addStringToSelection("find "); | 128 | m_PlayListSelection->addStringToSelection("find "); |
120 | m_PlayListSelection->addStringToSelection("free"); | 129 | m_PlayListSelection->addStringToSelection("free"); |
121 | m_PlayListSelection->addStringToSelection("grep "); | 130 | m_PlayListSelection->addStringToSelection("grep "); |
122 | m_PlayListSelection->addStringToSelection("ifconfig "); | 131 | m_PlayListSelection->addStringToSelection("ifconfig "); |
123 | m_PlayListSelection->addStringToSelection("ipkg "); | 132 | m_PlayListSelection->addStringToSelection("ipkg "); |
124 | m_PlayListSelection->addStringToSelection("mkdir "); | 133 | m_PlayListSelection->addStringToSelection("mkdir "); |
125 | m_PlayListSelection->addStringToSelection("mv "); | 134 | m_PlayListSelection->addStringToSelection("mv "); |
126 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); | 135 | m_PlayListSelection->addStringToSelection("nc localhost 7776"); |
127 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); | 136 | m_PlayListSelection->addStringToSelection("nc localhost 7777"); |
128 | m_PlayListSelection->addStringToSelection("nslookup "); | 137 | m_PlayListSelection->addStringToSelection("nslookup "); |
129 | m_PlayListSelection->addStringToSelection("ping "); | 138 | m_PlayListSelection->addStringToSelection("ping "); |
130 | m_PlayListSelection->addStringToSelection("ps aux"); | 139 | m_PlayListSelection->addStringToSelection("ps aux"); |
131 | m_PlayListSelection->addStringToSelection("pwd "); | 140 | m_PlayListSelection->addStringToSelection("pwd "); |
132 | m_PlayListSelection->addStringToSelection("rm "); | 141 | m_PlayListSelection->addStringToSelection("rm "); |
133 | m_PlayListSelection->addStringToSelection("rmdir "); | 142 | m_PlayListSelection->addStringToSelection("rmdir "); |
134 | m_PlayListSelection->addStringToSelection("route "); | 143 | m_PlayListSelection->addStringToSelection("route "); |
135 | m_PlayListSelection->addStringToSelection("set "); | 144 | m_PlayListSelection->addStringToSelection("set "); |
136 | m_PlayListSelection->addStringToSelection("traceroute"); | 145 | m_PlayListSelection->addStringToSelection("traceroute"); |
137 | 146 | ||
138 | } | 147 | } |
139 | } | 148 | } |
140 | CommandEditDialog::~CommandEditDialog() | 149 | CommandEditDialog::~CommandEditDialog() |
141 | { | 150 | { |
142 | } | 151 | } |
143 | 152 | ||
144 | void CommandEditDialog::accept() | 153 | void CommandEditDialog::accept() |
145 | { | 154 | { |
146 | int i = 0; | 155 | int i = 0; |
147 | Config *cfg = new Config("Konsole"); | 156 | Config *cfg = new Config("Konsole"); |
148 | cfg->setGroup("Commands"); | 157 | cfg->setGroup("Commands"); |
149 | cfg->clearGroup(); | 158 | cfg->clearGroup(); |
150 | 159 | ||
151 | QListViewItemIterator it( m_PlayListSelection ); | 160 | QListViewItemIterator it( m_PlayListSelection ); |
152 | 161 | ||
153 | for ( ; it.current(); ++it ) { | 162 | for ( ; it.current(); ++it ) { |
154 | // odebug << it.current()->text(0) << oendl; | 163 | // odebug << it.current()->text(0) << oendl; |
155 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 164 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
156 | i++; | 165 | i++; |
157 | 166 | ||
158 | } | 167 | } |
159 | cfg->writeEntry("Commands Set","TRUE"); | 168 | cfg->writeEntry("Commands Set","TRUE"); |
160 | // odebug << "CommandEditDialog::accept() - written" << oendl; | 169 | // odebug << "CommandEditDialog::accept() - written" << oendl; |
161 | delete cfg; | 170 | delete cfg; |
162 | emit commandsEdited(); | 171 | emit commandsEdited(); |
163 | close(); | 172 | close(); |
164 | 173 | ||
165 | 174 | ||
166 | 175 | ||
167 | 176 | ||
168 | 177 | ||
169 | } | 178 | } |
170 | 179 | ||
171 | void CommandEditDialog::showEditDialog() | 180 | void CommandEditDialog::showEditDialog() |
172 | { | 181 | { |
173 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 182 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
174 | d->setCaption("Edit command"); | 183 | d->setCaption("Edit command"); |
175 | d->TextLabel->setText("Edit command:"); | 184 | d->TextLabel->setText("Edit command:"); |
176 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); | 185 | d->commandEdit->setText(m_PlayListSelection->currentItem()->text(0)); |
177 | int i = d->exec(); | 186 | int i = d->exec(); |
178 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
179 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); | 188 | m_PlayListSelection->currentItem()->setText(0,(d->commandEdit->text())); |
180 | } | 189 | } |
181 | 190 | ||
182 | void CommandEditDialog::showAddDialog() | 191 | void CommandEditDialog::showAddDialog() |
183 | { | 192 | { |
184 | 193 | ||
185 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); | 194 | editCommandBase *d = new editCommandBase(this,"smalleditdialog", TRUE); |
186 | int i = d->exec(); | 195 | int i = d->exec(); |
187 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) | 196 | if ((i==1) && (!(d->commandEdit->text()).isEmpty())) |
188 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); | 197 | m_PlayListSelection->addStringToSelection(d->commandEdit->text()); |
189 | 198 | ||
190 | } | 199 | } |
191 | 200 | ||
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index de00494..7f3ea65 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,1909 +1,1918 @@ | |||
1 | 1 | ||
2 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
3 | /* */ | 3 | /* */ |
4 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
5 | /* */ | 5 | /* */ |
6 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
7 | /* */ | 7 | /* */ |
8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
9 | /* */ | 9 | /* */ |
10 | /* This file is part of Konsole, an X terminal. */ | 10 | /* This file is part of Konsole, an X terminal. */ |
11 | /* */ | 11 | /* */ |
12 | /* The material contained in here more or less directly orginates from */ | 12 | /* The material contained in here more or less directly orginates from */ |
13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ | 13 | /* kvt, which is copyright (c) 1996 by Matthias Ettrich <ettrich@kde.org> */ |
14 | /* */ | 14 | /* */ |
15 | /* ---------------------------------------------------------------------- */ | 15 | /* ---------------------------------------------------------------------- */ |
16 | /* */ | 16 | /* */ |
17 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
18 | /* */ | 18 | /* */ |
19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
20 | /* */ | 20 | /* */ |
21 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
23 | // enhancements added by Phillip Kuhn | 23 | // enhancements added by Phillip Kuhn |
24 | 24 | ||
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #ifdef QT_QWS_OPIE | 30 | #ifdef QT_QWS_OPIE |
31 | #include <opie2/ocolorpopupmenu.h> | 31 | #include <opie2/ocolorpopupmenu.h> |
32 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
33 | #include <opie2/oresource.h> | ||
34 | |||
33 | using namespace Opie; | 35 | using namespace Opie; |
34 | #endif | 36 | #endif |
35 | 37 | ||
36 | #include <qpe/resource.h> | ||
37 | |||
38 | #include <qmenubar.h> | 38 | #include <qmenubar.h> |
39 | #include <qtabbar.h> | 39 | #include <qtabbar.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qfontdatabase.h> | 41 | #include <qfontdatabase.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qspinbox.h> | 43 | #include <qspinbox.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | 45 | ||
46 | #include <sys/wait.h> | 46 | #include <sys/wait.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | #include <assert.h> | 49 | #include <assert.h> |
50 | 50 | ||
51 | #include "konsole.h" | 51 | #include "konsole.h" |
52 | #include "commandeditdialog.h" | 52 | #include "commandeditdialog.h" |
53 | 53 | ||
54 | class EKNumTabBar : public QTabBar | 54 | class EKNumTabBar : public QTabBar |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | 57 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : |
58 | QTabBar(parent, name) | 58 | QTabBar(parent, name) |
59 | {} | 59 | {} |
60 | 60 | ||
61 | // QList<QTab> *getTabList() { return(tabList()); } | 61 | // QList<QTab> *getTabList() { return(tabList()); } |
62 | 62 | ||
63 | void numberTabs() | 63 | void numberTabs() |
64 | { | 64 | { |
65 | // Yes, it really is this messy. QTabWidget needs functions | 65 | // Yes, it really is this messy. QTabWidget needs functions |
66 | // that provide acces to tabs in a sequential way. | 66 | // that provide acces to tabs in a sequential way. |
67 | int m=INT_MIN; | 67 | int m=INT_MIN; |
68 | for (int i=0; i<count(); i++) | 68 | for (int i=0; i<count(); i++) |
69 | { | 69 | { |
70 | QTab* left=0; | 70 | QTab* left=0; |
71 | QListIterator<QTab> it(*tabList()); | 71 | QListIterator<QTab> it(*tabList()); |
72 | int x=INT_MAX; | 72 | int x=INT_MAX; |
73 | for( QTab* t; (t=it.current()); ++it ) | 73 | for( QTab* t; (t=it.current()); ++it ) |
74 | { | 74 | { |
75 | int tx = t->rect().x(); | 75 | int tx = t->rect().x(); |
76 | if ( tx<x && tx>m ) | 76 | if ( tx<x && tx>m ) |
77 | { | 77 | { |
78 | x = tx; | 78 | x = tx; |
79 | left = t; | 79 | left = t; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if ( left ) | 82 | if ( left ) |
83 | { | 83 | { |
84 | left->setText(QString::number(i+1)); | 84 | left->setText(QString::number(i+1)); |
85 | m = left->rect().x(); | 85 | m = left->rect().x(); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | virtual QSize sizeHint() const | 90 | virtual QSize sizeHint() const |
91 | { | 91 | { |
92 | if (isHidden()) | 92 | if (isHidden()) |
93 | { | 93 | { |
94 | return(QSize(0,0)); | 94 | return(QSize(0,0)); |
95 | } | 95 | } |
96 | else | 96 | else |
97 | { | 97 | { |
98 | QSize size = QTabBar::sizeHint(); | 98 | QSize size = QTabBar::sizeHint(); |
99 | int shrink = 5; | 99 | int shrink = 5; |
100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | 100 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) |
101 | { | 101 | { |
102 | shrink = 10; | 102 | shrink = 10; |
103 | } | 103 | } |
104 | size.setHeight(size.height() - shrink); | 104 | size.setHeight(size.height() - shrink); |
105 | return(size); | 105 | return(size); |
106 | } | 106 | } |
107 | } | 107 | } |
108 | 108 | ||
109 | }; | 109 | }; |
110 | 110 | ||
111 | class EKNumTabWidget : public QTabWidget | 111 | class EKNumTabWidget : public QTabWidget |
112 | { | 112 | { |
113 | public: | 113 | public: |
114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 114 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
115 | { | 115 | { |
116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | 116 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); |
117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 117 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
118 | } | 118 | } |
119 | 119 | ||
120 | EKNumTabBar *getTabBar() const | 120 | EKNumTabBar *getTabBar() const |
121 | { | 121 | { |
122 | return ((EKNumTabBar*)tabBar()); | 122 | return ((EKNumTabBar*)tabBar()); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void addTab(QWidget* w) | 126 | void addTab(QWidget* w) |
127 | { | 127 | { |
128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 128 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
129 | QTabWidget::addTab(w,t); | 129 | QTabWidget::addTab(w,t); |
130 | } | 130 | } |
131 | 131 | ||
132 | void removeTab(QWidget* w) | 132 | void removeTab(QWidget* w) |
133 | { | 133 | { |
134 | removePage(w); | 134 | removePage(w); |
135 | ((EKNumTabBar*)tabBar())->numberTabs(); | 135 | ((EKNumTabBar*)tabBar())->numberTabs(); |
136 | } | 136 | } |
137 | }; | 137 | }; |
138 | 138 | ||
139 | // This could be configurable or dynamicly generated from the bash history | 139 | // This could be configurable or dynamicly generated from the bash history |
140 | // file of the user | 140 | // file of the user |
141 | static const char *commonCmds[] = | 141 | static const char *commonCmds[] = |
142 | { | 142 | { |
143 | "ls ", // I left this here, cause it looks better than the first alpha | 143 | "ls ", // I left this here, cause it looks better than the first alpha |
144 | "cardctl eject", | 144 | "cardctl eject", |
145 | "cat ", | 145 | "cat ", |
146 | "cd ", | 146 | "cd ", |
147 | "chmod ", | 147 | "chmod ", |
148 | "clear", | 148 | "clear", |
149 | "cp ", | 149 | "cp ", |
150 | "dc ", | 150 | "dc ", |
151 | "df ", | 151 | "df ", |
152 | "dmesg", | 152 | "dmesg", |
153 | "echo ", | 153 | "echo ", |
154 | "env", | 154 | "env", |
155 | "find ", | 155 | "find ", |
156 | "free", | 156 | "free", |
157 | "grep ", | 157 | "grep ", |
158 | "ifconfig ", | 158 | "ifconfig ", |
159 | "ipkg ", | 159 | "ipkg ", |
160 | "mkdir ", | 160 | "mkdir ", |
161 | "mv ", | 161 | "mv ", |
162 | "nc localhost 7776", | 162 | "nc localhost 7776", |
163 | "nc localhost 7777", | 163 | "nc localhost 7777", |
164 | "netstat ", | 164 | "netstat ", |
165 | "nslookup ", | 165 | "nslookup ", |
166 | "ping ", | 166 | "ping ", |
167 | "ps aux", | 167 | "ps aux", |
168 | "pwd ", | 168 | "pwd ", |
169 | // "qcop QPE/System 'linkChanged(QString)' ''", | 169 | // "qcop QPE/System 'linkChanged(QString)' ''", |
170 | // "qcop QPE/System 'restart()'", | 170 | // "qcop QPE/System 'restart()'", |
171 | // "qcop QPE/System 'quit()'", | 171 | // "qcop QPE/System 'quit()'", |
172 | "rm ", | 172 | "rm ", |
173 | "rmdir ", | 173 | "rmdir ", |
174 | "route ", | 174 | "route ", |
175 | "set ", | 175 | "set ", |
176 | "traceroute", | 176 | "traceroute", |
177 | 177 | ||
178 | /* | 178 | /* |
179 | "gzip", | 179 | "gzip", |
180 | "gunzip", | 180 | "gunzip", |
181 | "chgrp", | 181 | "chgrp", |
182 | "chown", | 182 | "chown", |
183 | "date", | 183 | "date", |
184 | "dd", | 184 | "dd", |
185 | "df", | 185 | "df", |
186 | "dmesg", | 186 | "dmesg", |
187 | "fuser", | 187 | "fuser", |
188 | "hostname", | 188 | "hostname", |
189 | "kill", | 189 | "kill", |
190 | "killall", | 190 | "killall", |
191 | "ln", | 191 | "ln", |
192 | "ping", | 192 | "ping", |
193 | "mount", | 193 | "mount", |
194 | "more", | 194 | "more", |
195 | "sort", | 195 | "sort", |
196 | "touch", | 196 | "touch", |
197 | "umount", | 197 | "umount", |
198 | "mknod", | 198 | "mknod", |
199 | "netstat", | 199 | "netstat", |
200 | */ | 200 | */ |
201 | 201 | ||
202 | "exit", | 202 | "exit", |
203 | NULL | 203 | NULL |
204 | }; | 204 | }; |
205 | 205 | ||
206 | 206 | ||
207 | static void konsoleInit(const char** shell) { | 207 | static void konsoleInit(const char** shell) { |
208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; | 208 | if(setuid(getuid()) !=0) odebug << "setuid failed" << oendl; |
209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges | 209 | if(setgid(getgid()) != 0) odebug << "setgid failed" << oendl; // drop privileges |
210 | 210 | ||
211 | 211 | ||
212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 212 | // QPEApplication::grabKeyboard(); // for CTRL and ALT |
213 | 213 | ||
214 | odebug << "keyboard grabbed" << oendl; | 214 | odebug << "keyboard grabbed" << oendl; |
215 | #ifdef FAKE_CTRL_AND_ALT | 215 | #ifdef FAKE_CTRL_AND_ALT |
216 | odebug << "Fake Ctrl and Alt defined" << oendl; | 216 | odebug << "Fake Ctrl and Alt defined" << oendl; |
217 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 217 | QPEApplication::grabKeyboard(); // for CTRL and ALT |
218 | #endif | 218 | #endif |
219 | 219 | ||
220 | *shell = getenv("SHELL"); | 220 | *shell = getenv("SHELL"); |
221 | owarn << "SHell initially is " << *shell << "" << oendl; | 221 | owarn << "SHell initially is " << *shell << "" << oendl; |
222 | 222 | ||
223 | if (shell == NULL || *shell == '\0') { | 223 | if (shell == NULL || *shell == '\0') { |
224 | struct passwd *ent = 0; | 224 | struct passwd *ent = 0; |
225 | uid_t me = getuid(); | 225 | uid_t me = getuid(); |
226 | *shell = "/bin/sh"; | 226 | *shell = "/bin/sh"; |
227 | 227 | ||
228 | while ( (ent = getpwent()) != 0 ) { | 228 | while ( (ent = getpwent()) != 0 ) { |
229 | if (ent->pw_uid == me) { | 229 | if (ent->pw_uid == me) { |
230 | if (ent->pw_shell != "") | 230 | if (ent->pw_shell != "") |
231 | *shell = ent->pw_shell; | 231 | *shell = ent->pw_shell; |
232 | break; | 232 | break; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | endpwent(); | 235 | endpwent(); |
236 | } | 236 | } |
237 | 237 | ||
238 | if( putenv((char*)"COLORTERM=") !=0) | 238 | if( putenv((char*)"COLORTERM=") !=0) |
239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection | 239 | odebug << "putenv failed" << oendl; // to trigger mc's color detection |
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 243 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
244 | QMainWindow(parent, name, fl) | 244 | QMainWindow(parent, name, fl) |
245 | { | 245 | { |
246 | QStrList tmp; const char* shell; | 246 | QStrList tmp; const char* shell; |
247 | 247 | ||
248 | konsoleInit( &shell); | 248 | konsoleInit( &shell); |
249 | init(shell,tmp); | 249 | init(shell,tmp); |
250 | } | 250 | } |
251 | 251 | ||
252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) | 252 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
253 | : QMainWindow(0, name) | 253 | : QMainWindow(0, name) |
254 | { | 254 | { |
255 | init(_pgm,_args); | 255 | init(_pgm,_args); |
256 | } | 256 | } |
257 | 257 | ||
258 | struct HistoryItem | 258 | struct HistoryItem |
259 | { | 259 | { |
260 | HistoryItem(int c, const QString &l) | 260 | HistoryItem(int c, const QString &l) |
261 | { | 261 | { |
262 | count = c; | 262 | count = c; |
263 | line = l; | 263 | line = l; |
264 | } | 264 | } |
265 | int count; | 265 | int count; |
266 | QString line; | 266 | QString line; |
267 | }; | 267 | }; |
268 | 268 | ||
269 | class HistoryList : public QList<HistoryItem> | 269 | class HistoryList : public QList<HistoryItem> |
270 | { | 270 | { |
271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | 271 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) |
272 | { | 272 | { |
273 | int c1 = ((HistoryItem*)item1)->count; | 273 | int c1 = ((HistoryItem*)item1)->count; |
274 | int c2 = ((HistoryItem*)item2)->count; | 274 | int c2 = ((HistoryItem*)item2)->count; |
275 | if (c1 > c2) | 275 | if (c1 > c2) |
276 | return(1); | 276 | return(1); |
277 | if (c1 < c2) | 277 | if (c1 < c2) |
278 | return(-1); | 278 | return(-1); |
279 | return(0); | 279 | return(0); |
280 | } | 280 | } |
281 | }; | 281 | }; |
282 | 282 | ||
283 | void Konsole::initCommandList() | 283 | void Konsole::initCommandList() |
284 | { | 284 | { |
285 | // odebug << "Konsole::initCommandList" << oendl; | 285 | // odebug << "Konsole::initCommandList" << oendl; |
286 | Config cfg( "Konsole" ); | 286 | Config cfg( "Konsole" ); |
287 | cfg.setGroup("Commands"); | 287 | cfg.setGroup("Commands"); |
288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 288 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
289 | commonCombo->clear(); | 289 | commonCombo->clear(); |
290 | 290 | ||
291 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { | 291 | if (cfg.readEntry("ShellHistory","TRUE") == "FALSE") { |
292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; | 292 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); | 293 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
294 | QFile histfile(histfilename); | 294 | QFile histfile(histfilename); |
295 | // note: compiler barfed on: | 295 | // note: compiler barfed on: |
296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | 296 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); |
297 | if (histfile.open( IO_ReadOnly )) { | 297 | if (histfile.open( IO_ReadOnly )) { |
298 | QString line; | 298 | QString line; |
299 | uint i; | 299 | uint i; |
300 | HistoryList items; | 300 | HistoryList items; |
301 | 301 | ||
302 | int lineno = 0; | 302 | int lineno = 0; |
303 | while(!histfile.atEnd()) { | 303 | while(!histfile.atEnd()) { |
304 | if (histfile.readLine(line, 200) < 0) { | 304 | if (histfile.readLine(line, 200) < 0) { |
305 | break; | 305 | break; |
306 | } | 306 | } |
307 | line = line.left(line.length()-1); | 307 | line = line.left(line.length()-1); |
308 | lineno++; | 308 | lineno++; |
309 | 309 | ||
310 | for(i=0; i<items.count(); i++) { | 310 | for(i=0; i<items.count(); i++) { |
311 | if (line == items.at(i)->line) { | 311 | if (line == items.at(i)->line) { |
312 | // weight recent commands & repeated commands more | 312 | // weight recent commands & repeated commands more |
313 | // by adding up the index of each command | 313 | // by adding up the index of each command |
314 | items.at(i)->count += lineno; | 314 | items.at(i)->count += lineno; |
315 | break; | 315 | break; |
316 | } | 316 | } |
317 | } | 317 | } |
318 | if (i >= items.count()) { | 318 | if (i >= items.count()) { |
319 | items.append(new HistoryItem(lineno, line)); | 319 | items.append(new HistoryItem(lineno, line)); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | items.sort(); | 322 | items.sort(); |
323 | int n = items.count(); | 323 | int n = items.count(); |
324 | if (n > 40) { | 324 | if (n > 40) { |
325 | n = 40; | 325 | n = 40; |
326 | } | 326 | } |
327 | for(int i=0; i<n; i++) { | 327 | for(int i=0; i<n; i++) { |
328 | // should insert start of command, but keep whole thing | 328 | // should insert start of command, but keep whole thing |
329 | if (items.at(items.count()-i-1)->line.length() < 30) { | 329 | if (items.at(items.count()-i-1)->line.length() < 30) { |
330 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | 330 | commonCombo->insertItem(items.at(items.count()-i-1)->line); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | histfile.close(); | 333 | histfile.close(); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 336 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { |
337 | for (int i = 0; commonCmds[i] != NULL; i++) { | 337 | for (int i = 0; commonCmds[i] != NULL; i++) { |
338 | commonCombo->insertItem(commonCmds[i]); | 338 | commonCombo->insertItem(commonCmds[i]); |
339 | } | 339 | } |
340 | } else { | 340 | } else { |
341 | for (int i = 0; i < 100; i++) { | 341 | for (int i = 0; i < 100; i++) { |
342 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 342 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) |
343 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | 343 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | } | 348 | } |
349 | 349 | ||
350 | static void sig_handler(int x) | 350 | static void sig_handler(int x) |
351 | { | 351 | { |
352 | printf("got signal %d\n",x); | 352 | printf("got signal %d\n",x); |
353 | } | 353 | } |
354 | 354 | ||
355 | void Konsole::init(const char* _pgm, QStrList & _args) | 355 | void Konsole::init(const char* _pgm, QStrList & _args) |
356 | { | 356 | { |
357 | 357 | ||
358 | #if 0 | 358 | #if 0 |
359 | for(int i=1; i<=31; i++) | 359 | for(int i=1; i<=31; i++) |
360 | { | 360 | { |
361 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV | 361 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
362 | && i != SIGINT && i != SIGILL && i != SIGTERM | 362 | && i != SIGINT && i != SIGILL && i != SIGTERM |
363 | && i != SIGBUS) | 363 | && i != SIGBUS) |
364 | signal(i,sig_handler); | 364 | signal(i,sig_handler); |
365 | } | 365 | } |
366 | #endif | 366 | #endif |
367 | signal(SIGSTOP, sig_handler); | 367 | signal(SIGSTOP, sig_handler); |
368 | signal(SIGCONT, sig_handler); | 368 | signal(SIGCONT, sig_handler); |
369 | signal(SIGTSTP, sig_handler); | 369 | signal(SIGTSTP, sig_handler); |
370 | 370 | ||
371 | b_scroll = TRUE; // histon; | 371 | b_scroll = TRUE; // histon; |
372 | n_keytab = 0; | 372 | n_keytab = 0; |
373 | n_render = 0; | 373 | n_render = 0; |
374 | startUp=0; | 374 | startUp=0; |
375 | fromMenu = FALSE; | 375 | fromMenu = FALSE; |
376 | fullscreen = false; | 376 | fullscreen = false; |
377 | 377 | ||
378 | setCaption( tr( "Konsole" ) ); | 378 | setCaption( tr( "Konsole" ) ); |
379 | setIcon( Resource::loadPixmap( "konsole/Terminal" ) ); | 379 | setIcon( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ) ); |
380 | 380 | ||
381 | Config cfg( "Konsole" ); | 381 | Config cfg( "Konsole" ); |
382 | cfg.setGroup("Font"); | 382 | cfg.setGroup("Font"); |
383 | QString tmp; | 383 | QString tmp; |
384 | 384 | ||
385 | // initialize the list of allowed fonts /////////////////////////////////// | 385 | // initialize the list of allowed fonts /////////////////////////////////// |
386 | 386 | ||
387 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | 387 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); |
388 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | 388 | int cfgFontSize = cfg.readNumEntry("FontSize",18); |
389 | 389 | ||
390 | cfont = -1; | 390 | cfont = -1; |
391 | 391 | ||
392 | // this code causes repeated access to all the font files | 392 | // this code causes repeated access to all the font files |
393 | // which does slow down startup | 393 | // which does slow down startup |
394 | QFontDatabase fontDB; | 394 | QFontDatabase fontDB; |
395 | QStringList familyNames; | 395 | QStringList familyNames; |
396 | familyNames = fontDB.families( FALSE ); | 396 | familyNames = fontDB.families( FALSE ); |
397 | QString s; | 397 | QString s; |
398 | int fontIndex = 0; | 398 | int fontIndex = 0; |
399 | int familyNum = 0; | 399 | int familyNum = 0; |
400 | fontList = new QPopupMenu( this ); | 400 | fontList = new QPopupMenu( this ); |
401 | 401 | ||
402 | for(uint j = 0; j < (uint)familyNames.count(); j++) | 402 | for(uint j = 0; j < (uint)familyNames.count(); j++) |
403 | { | 403 | { |
404 | s = familyNames[j]; | 404 | s = familyNames[j]; |
405 | if ( s.contains('-') ) | 405 | if ( s.contains('-') ) |
406 | { | 406 | { |
407 | int i = s.find('-'); | 407 | int i = s.find('-'); |
408 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | 408 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; |
409 | } | 409 | } |
410 | s[0] = s[0].upper(); | 410 | s[0] = s[0].upper(); |
411 | 411 | ||
412 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); | 412 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
413 | 413 | ||
414 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | 414 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), |
415 | sizes.count()); | 415 | sizes.count()); |
416 | 416 | ||
417 | if (sizes.count() > 0) | 417 | if (sizes.count() > 0) |
418 | { | 418 | { |
419 | QPopupMenu *sizeMenu; | 419 | QPopupMenu *sizeMenu; |
420 | QFont f; | 420 | QFont f; |
421 | int last_width = -1; | 421 | int last_width = -1; |
422 | sizeMenu = NULL; | 422 | sizeMenu = NULL; |
423 | 423 | ||
424 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | 424 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) |
425 | { | 425 | { |
426 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | 426 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); |
427 | // need to divide by 10 on the Z, but not otherwise | 427 | // need to divide by 10 on the Z, but not otherwise |
428 | int size; | 428 | int size; |
429 | 429 | ||
430 | if (i >= (uint)sizes.count()) | 430 | if (i >= (uint)sizes.count()) |
431 | { | 431 | { |
432 | // try for expandable fonts | 432 | // try for expandable fonts |
433 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | 433 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); |
434 | } | 434 | } |
435 | else | 435 | else |
436 | { | 436 | { |
437 | printf("sizes[%d] = %d\n", i, sizes[i]); | 437 | printf("sizes[%d] = %d\n", i, sizes[i]); |
438 | size = sizes[i]; | 438 | size = sizes[i]; |
439 | } | 439 | } |
440 | 440 | ||
441 | f = QFont(familyNames[j], size); | 441 | f = QFont(familyNames[j], size); |
442 | f.setFixedPitch(true); | 442 | f.setFixedPitch(true); |
443 | QFontMetrics fm(f); | 443 | QFontMetrics fm(f); |
444 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | 444 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! |
445 | if (fm.width("l") == fm.width("m") | 445 | if (fm.width("l") == fm.width("m") |
446 | && (i < (uint)sizes.count() | 446 | && (i < (uint)sizes.count() |
447 | || fm.width("m") > last_width)) | 447 | || fm.width("m") > last_width)) |
448 | { | 448 | { |
449 | if (i < (uint)sizes.count()) | 449 | if (i < (uint)sizes.count()) |
450 | { | 450 | { |
451 | last_width = fm.width("m"); | 451 | last_width = fm.width("m"); |
452 | } | 452 | } |
453 | if (sizeMenu == NULL) | 453 | if (sizeMenu == NULL) |
454 | { | 454 | { |
455 | sizeMenu = new QPopupMenu(); | 455 | sizeMenu = new QPopupMenu(); |
456 | } | 456 | } |
457 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | 457 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); |
458 | sizeMenu->setItemParameter(id, fontIndex); | 458 | sizeMenu->setItemParameter(id, fontIndex); |
459 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | 459 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); |
460 | QString name = s + " " + QString::number(size); | 460 | QString name = s + " " + QString::number(size); |
461 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | 461 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); |
462 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | 462 | if (familyNames[j] == cfgFontName && size == cfgFontSize) |
463 | { | 463 | { |
464 | cfont = fontIndex; | 464 | cfont = fontIndex; |
465 | } | 465 | } |
466 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | 466 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); |
467 | fontIndex++; | 467 | fontIndex++; |
468 | } | 468 | } |
469 | } | 469 | } |
470 | if (sizeMenu) | 470 | if (sizeMenu) |
471 | { | 471 | { |
472 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | 472 | fontList->insertItem(s, sizeMenu, familyNum + 1000); |
473 | 473 | ||
474 | familyNum++; | 474 | familyNum++; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | 477 | ||
478 | } | 478 | } |
479 | 479 | ||
480 | if (cfont < 0 || cfont >= (int)fonts.count()) | 480 | if (cfont < 0 || cfont >= (int)fonts.count()) |
481 | { | 481 | { |
482 | cfont = 0; | 482 | cfont = 0; |
483 | } | 483 | } |
484 | 484 | ||
485 | // create terminal emulation framework //////////////////////////////////// | 485 | // create terminal emulation framework //////////////////////////////////// |
486 | nsessions = 0; | 486 | nsessions = 0; |
487 | 487 | ||
488 | tab = new EKNumTabWidget(this); | 488 | tab = new EKNumTabWidget(this); |
489 | // tab->setMargin(tab->margin()-5); | 489 | // tab->setMargin(tab->margin()-5); |
490 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | 490 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
491 | 491 | ||
492 | // create terminal toolbar //////////////////////////////////////////////// | 492 | // create terminal toolbar //////////////////////////////////////////////// |
493 | setToolBarsMovable( FALSE ); | 493 | setToolBarsMovable( FALSE ); |
494 | menuToolBar = new QToolBar( this ); | 494 | menuToolBar = new QToolBar( this ); |
495 | menuToolBar->setHorizontalStretchable( TRUE ); | 495 | menuToolBar->setHorizontalStretchable( TRUE ); |
496 | 496 | ||
497 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | 497 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
498 | 498 | ||
499 | setFont(cfont); | 499 | setFont(cfont); |
500 | 500 | ||
501 | configMenu = new QPopupMenu( this); | 501 | configMenu = new QPopupMenu( this); |
502 | colorMenu = new QPopupMenu( this); | 502 | colorMenu = new QPopupMenu( this); |
503 | scrollMenu = new QPopupMenu( this); | 503 | scrollMenu = new QPopupMenu( this); |
504 | editCommandListMenu = new QPopupMenu( this); | 504 | editCommandListMenu = new QPopupMenu( this); |
505 | 505 | ||
506 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 506 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
507 | 507 | ||
508 | bool listHidden; | 508 | bool listHidden; |
509 | cfg.setGroup("Menubar"); | 509 | cfg.setGroup("Menubar"); |
510 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") | 510 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
511 | { | 511 | { |
512 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); | 512 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
513 | listHidden=TRUE; | 513 | listHidden=TRUE; |
514 | } | 514 | } |
515 | else | 515 | else |
516 | { | 516 | { |
517 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); | 517 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
518 | listHidden=FALSE; | 518 | listHidden=FALSE; |
519 | } | 519 | } |
520 | 520 | ||
521 | cfg.setGroup("Tabs"); | 521 | cfg.setGroup("Tabs"); |
522 | 522 | ||
523 | tabMenu = new QPopupMenu(this); | 523 | tabMenu = new QPopupMenu(this); |
524 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); | 524 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
525 | tm_top = tabMenu->insertItem(tr("Top")); | 525 | tm_top = tabMenu->insertItem(tr("Top")); |
526 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | 526 | tm_hidden = tabMenu->insertItem(tr("Hidden")); |
527 | 527 | ||
528 | configMenu->insertItem(tr("Tabs"), tabMenu); | 528 | configMenu->insertItem(tr("Tabs"), tabMenu); |
529 | 529 | ||
530 | tmp=cfg.readEntry("Position","Top"); | 530 | tmp=cfg.readEntry("Position","Top"); |
531 | if(tmp=="Top") | 531 | if(tmp=="Top") |
532 | { | 532 | { |
533 | tab->setTabPosition(QTabWidget::Top); | 533 | tab->setTabPosition(QTabWidget::Top); |
534 | tab->getTabBar()->show(); | 534 | tab->getTabBar()->show(); |
535 | tabPos = tm_top; | 535 | tabPos = tm_top; |
536 | } | 536 | } |
537 | else if (tmp=="Bottom") | 537 | else if (tmp=="Bottom") |
538 | { | 538 | { |
539 | tab->setTabPosition(QTabWidget::Bottom); | 539 | tab->setTabPosition(QTabWidget::Bottom); |
540 | tab->getTabBar()->show(); | 540 | tab->getTabBar()->show(); |
541 | tabPos = tm_bottom; | 541 | tabPos = tm_bottom; |
542 | } | 542 | } |
543 | else | 543 | else |
544 | { | 544 | { |
545 | tab->getTabBar()->hide(); | 545 | tab->getTabBar()->hide(); |
546 | tab->setMargin(tab->margin()); | 546 | tab->setMargin(tab->margin()); |
547 | tabPos = tm_hidden; | 547 | tabPos = tm_hidden; |
548 | } | 548 | } |
549 | 549 | ||
550 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | 550 | cm_bw = colorMenu->insertItem(tr( "Black on White")); |
551 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | 551 | cm_wb = colorMenu->insertItem(tr( "White on Black")); |
552 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | 552 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); |
553 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | 553 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); |
554 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | 554 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); |
555 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | 555 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); |
556 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | 556 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); |
557 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | 557 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); |
558 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | 558 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); |
559 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | 559 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); |
560 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | 560 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); |
561 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | 561 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); |
562 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | 562 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); |
563 | cm_default = colorMenu->insertItem(tr("default")); | 563 | cm_default = colorMenu->insertItem(tr("default")); |
564 | 564 | ||
565 | #ifdef QT_QWS_OPIE | 565 | #ifdef QT_QWS_OPIE |
566 | 566 | ||
567 | colorMenu->insertItem(tr( "Custom")); | 567 | colorMenu->insertItem(tr( "Custom")); |
568 | #endif | 568 | #endif |
569 | 569 | ||
570 | configMenu->insertItem(tr( "Colors") ,colorMenu); | 570 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
571 | 571 | ||
572 | sessionList = new QPopupMenu(this); | 572 | sessionList = new QPopupMenu(this); |
573 | sessionList-> insertItem ( Resource::loadPixmap ( "konsole/Terminal" ), tr( "new session" ), this, | 573 | sessionList-> insertItem ( Opie::Core::OResource::loadPixmap( "konsole/Terminal", Opie::Core::OResource::SmallIcon ), |
574 | SLOT(newSession()) ); | 574 | tr( "new session" ), this, SLOT(newSession()) ); |
575 | 575 | ||
576 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | 576 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
577 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | 577 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
578 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | 578 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); |
579 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | 579 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); |
580 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | 580 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); |
581 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | 581 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); |
582 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | 582 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); |
583 | 583 | ||
584 | menuBar->insertItem( tr("View"), configMenu ); | 584 | menuBar->insertItem( tr("View"), configMenu ); |
585 | menuBar->insertItem( tr("Fonts"), fontList ); | 585 | menuBar->insertItem( tr("Fonts"), fontList ); |
586 | menuBar->insertItem( tr("Sessions"), sessionList ); | 586 | menuBar->insertItem( tr("Sessions"), sessionList ); |
587 | 587 | ||
588 | toolBar = new QToolBar( this ); | 588 | toolBar = new QToolBar( this ); |
589 | 589 | ||
590 | QAction *a; | 590 | QAction *a; |
591 | 591 | ||
592 | // Button Commands | 592 | // Button Commands |
593 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/konsole" ), QString::null, 0, this, 0 ); | 593 | a = new QAction( tr("New"), Opie::Core::OResource::loadPixmap( "konsole/konsole", Opie::Core::OResource::SmallIcon ), |
594 | QString::null, 0, this, 0 ); | ||
594 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); | 595 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
595 | a->addTo( toolBar ); | 596 | a->addTo( toolBar ); |
596 | 597 | ||
597 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 598 | a = new QAction( tr("Full Screen"), Opie::Core::OResource::loadPixmap( "fullscreen", Opie::Core::OResource::SmallIcon ), |
599 | QString::null, 0, this, 0 ); | ||
598 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | 600 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); |
599 | a->addTo( toolBar ); | 601 | a->addTo( toolBar ); |
600 | 602 | ||
601 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); | 603 | a = new QAction( tr("Zoom"), Opie::Core::OResource::loadPixmap( "zoom", Opie::Core::OResource::SmallIcon ), |
604 | QString::null, 0, this, 0 ); | ||
602 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); | 605 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
603 | a->addTo( toolBar ); | 606 | a->addTo( toolBar ); |
604 | 607 | ||
605 | 608 | ||
606 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | 609 | a = new QAction( tr("Enter"), Opie::Core::OResource::loadPixmap( "konsole/enter", Opie::Core::OResource::SmallIcon ), |
610 | QString::null, 0, this, 0 ); | ||
607 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | 611 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); |
608 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | 612 | a = new QAction( tr("Space"), Opie::Core::OResource::loadPixmap( "konsole/space", Opie::Core::OResource::SmallIcon ), |
613 | QString::null, 0, this, 0 ); | ||
609 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | 614 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); |
610 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | 615 | a = new QAction( tr("Tab"), Opie::Core::OResource::loadPixmap( "konsole/tab", Opie::Core::OResource::SmallIcon ), |
616 | QString::null, 0, this, 0 ); | ||
611 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | 617 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); |
612 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | 618 | a = new QAction( tr("Up"), Opie::Core::OResource::loadPixmap( "konsole/up", Opie::Core::OResource::SmallIcon ), |
619 | QString::null, 0, this, 0 ); | ||
613 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | 620 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); |
614 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | 621 | a = new QAction( tr("Down"), Opie::Core::OResource::loadPixmap( "konsole/down", Opie::Core::OResource::SmallIcon ), |
622 | QString::null, 0, this, 0 ); | ||
615 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | 623 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); |
616 | 624 | ||
617 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 625 | a = new QAction( tr("Paste"), Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ), |
626 | QString::null, 0, this, 0 ); | ||
618 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | 627 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); |
619 | a->addTo( toolBar ); | 628 | a->addTo( toolBar ); |
620 | 629 | ||
621 | secondToolBar = new QToolBar( this ); | 630 | secondToolBar = new QToolBar( this ); |
622 | secondToolBar->setHorizontalStretchable( TRUE ); | 631 | secondToolBar->setHorizontalStretchable( TRUE ); |
623 | 632 | ||
624 | commonCombo = new QComboBox( secondToolBar ); | 633 | commonCombo = new QComboBox( secondToolBar ); |
625 | // commonCombo->setMaximumWidth(236); | 634 | // commonCombo->setMaximumWidth(236); |
626 | 635 | ||
627 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 636 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); |
628 | if( listHidden) | 637 | if( listHidden) |
629 | { | 638 | { |
630 | secondToolBar->hide(); | 639 | secondToolBar->hide(); |
631 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | 640 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); |
632 | } | 641 | } |
633 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); | 642 | ec_edit = editCommandListMenu->insertItem(tr( "Edit..." ) ); |
634 | 643 | ||
635 | cfg.setGroup("Commands"); | 644 | cfg.setGroup("Commands"); |
636 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 645 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); |
637 | 646 | ||
638 | initCommandList(); | 647 | initCommandList(); |
639 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 648 | // for (int i = 0; commonCmds[i] != NULL; i++) { |
640 | // commonCombo->insertItem( commonCmds[i], i ); | 649 | // commonCombo->insertItem( commonCmds[i], i ); |
641 | // tmp = cfg.readEntry( QString::number(i),""); | 650 | // tmp = cfg.readEntry( QString::number(i),""); |
642 | // if(tmp != "") | 651 | // if(tmp != "") |
643 | // commonCombo->changeItem( tmp,i ); | 652 | // commonCombo->changeItem( tmp,i ); |
644 | // } | 653 | // } |
645 | 654 | ||
646 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 655 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); |
647 | 656 | ||
648 | sm_none = scrollMenu->insertItem(tr( "None" )); | 657 | sm_none = scrollMenu->insertItem(tr( "None" )); |
649 | sm_left = scrollMenu->insertItem(tr( "Left" )); | 658 | sm_left = scrollMenu->insertItem(tr( "Left" )); |
650 | sm_right = scrollMenu->insertItem(tr( "Right" )); | 659 | sm_right = scrollMenu->insertItem(tr( "Right" )); |
651 | // scrollMenu->insertSeparator(4); | 660 | // scrollMenu->insertSeparator(4); |
652 | // scrollMenu->insertItem(tr( "Horizontal" )); | 661 | // scrollMenu->insertItem(tr( "Horizontal" )); |
653 | 662 | ||
654 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | 663 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); |
655 | 664 | ||
656 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); | 665 | configMenu->insertItem(tr( "History..." ), this, SLOT(historyDialog())); |
657 | 666 | ||
658 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | 667 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); |
659 | cfg.setGroup("ScrollBar"); | 668 | cfg.setGroup("ScrollBar"); |
660 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); | 669 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
661 | 670 | ||
662 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); | 671 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
663 | cfg.setGroup("Menubar"); | 672 | cfg.setGroup("Menubar"); |
664 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | 673 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); |
665 | 674 | ||
666 | fullscreen_msg = new QLabel(this); | 675 | fullscreen_msg = new QLabel(this); |
667 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | 676 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); |
668 | fullscreen_msg-> hide(); | 677 | fullscreen_msg-> hide(); |
669 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); | 678 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
670 | fullscreen_msg-> setAutoResize(true); | 679 | fullscreen_msg-> setAutoResize(true); |
671 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 680 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
672 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); | 681 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
673 | 682 | ||
674 | fullscreen_timer = new QTimer(this); | 683 | fullscreen_timer = new QTimer(this); |
675 | connect(fullscreen_timer, SIGNAL(timeout()), | 684 | connect(fullscreen_timer, SIGNAL(timeout()), |
676 | this, SLOT(fullscreenTimeout())); | 685 | this, SLOT(fullscreenTimeout())); |
677 | show_fullscreen_msg = true; | 686 | show_fullscreen_msg = true; |
678 | 687 | ||
679 | //scrollMenuSelected(-29); | 688 | //scrollMenuSelected(-29); |
680 | // cfg.setGroup("ScrollBar"); | 689 | // cfg.setGroup("ScrollBar"); |
681 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 690 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
682 | // if(cfg.readNumEntry("Position",2) == 0) | 691 | // if(cfg.readNumEntry("Position",2) == 0) |
683 | // te->setScrollbarLocation(1); | 692 | // te->setScrollbarLocation(1); |
684 | // else | 693 | // else |
685 | // te->setScrollbarLocation(0); | 694 | // te->setScrollbarLocation(0); |
686 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 695 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
687 | // te->setWrapAt(120); | 696 | // te->setWrapAt(120); |
688 | // } | 697 | // } |
689 | // create applications ///////////////////////////////////////////////////// | 698 | // create applications ///////////////////////////////////////////////////// |
690 | setCentralWidget(tab); | 699 | setCentralWidget(tab); |
691 | 700 | ||
692 | // load keymaps //////////////////////////////////////////////////////////// | 701 | // load keymaps //////////////////////////////////////////////////////////// |
693 | KeyTrans::loadAll(); | 702 | KeyTrans::loadAll(); |
694 | for (int i = 0; i < KeyTrans::count(); i++) | 703 | for (int i = 0; i < KeyTrans::count(); i++) |
695 | { | 704 | { |
696 | KeyTrans* s = KeyTrans::find(i); | 705 | KeyTrans* s = KeyTrans::find(i); |
697 | assert( s ); | 706 | assert( s ); |
698 | } | 707 | } |
699 | 708 | ||
700 | se_pgm = _pgm; | 709 | se_pgm = _pgm; |
701 | se_args = _args; | 710 | se_args = _args; |
702 | 711 | ||
703 | cfg.setGroup("CommandLine"); | 712 | cfg.setGroup("CommandLine"); |
704 | 713 | ||
705 | if (cfg.hasKey("shell_args")) | 714 | if (cfg.hasKey("shell_args")) |
706 | { | 715 | { |
707 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); | 716 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
708 | for(uint i = 0; i < se_args_list.count(); i++) | 717 | for(uint i = 0; i < se_args_list.count(); i++) |
709 | { | 718 | { |
710 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); | 719 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
711 | } | 720 | } |
712 | } | 721 | } |
713 | else | 722 | else |
714 | { | 723 | { |
715 | se_args.prepend("--login"); | 724 | se_args.prepend("--login"); |
716 | } | 725 | } |
717 | 726 | ||
718 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | 727 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); |
719 | 728 | ||
720 | // this is the "documentation" for those who know to look | 729 | // this is the "documentation" for those who know to look |
721 | if (! cfg.hasKey("shell_args")) | 730 | if (! cfg.hasKey("shell_args")) |
722 | { | 731 | { |
723 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | 732 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); |
724 | } | 733 | } |
725 | if (! cfg.hasKey("shell_bin")) | 734 | if (! cfg.hasKey("shell_bin")) |
726 | { | 735 | { |
727 | cfg.writeEntry("shell_bin",QString(se_pgm)); | 736 | cfg.writeEntry("shell_bin",QString(se_pgm)); |
728 | } | 737 | } |
729 | 738 | ||
730 | parseCommandLine(); | 739 | parseCommandLine(); |
731 | 740 | ||
732 | // read and apply default values /////////////////////////////////////////// | 741 | // read and apply default values /////////////////////////////////////////// |
733 | resize(321, 321); // Dummy. | 742 | resize(321, 321); // Dummy. |
734 | QSize currentSize = size(); | 743 | QSize currentSize = size(); |
735 | if (currentSize != size()) | 744 | if (currentSize != size()) |
736 | defaultSize = size(); | 745 | defaultSize = size(); |
737 | 746 | ||
738 | 747 | ||
739 | /* allows us to catch cancel/escape */ | 748 | /* allows us to catch cancel/escape */ |
740 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 749 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
741 | QPoint ( 0, 0 )); | 750 | QPoint ( 0, 0 )); |
742 | } | 751 | } |
743 | 752 | ||
744 | void Konsole::show() | 753 | void Konsole::show() |
745 | { | 754 | { |
746 | if ( !nsessions ) | 755 | if ( !nsessions ) |
747 | { | 756 | { |
748 | newSession(); | 757 | newSession(); |
749 | } | 758 | } |
750 | QMainWindow::show(); | 759 | QMainWindow::show(); |
751 | 760 | ||
752 | } | 761 | } |
753 | 762 | ||
754 | void Konsole::initSession(const char*, QStrList &) | 763 | void Konsole::initSession(const char*, QStrList &) |
755 | { | 764 | { |
756 | QMainWindow::show(); | 765 | QMainWindow::show(); |
757 | } | 766 | } |
758 | 767 | ||
759 | Konsole::~Konsole() | 768 | Konsole::~Konsole() |
760 | { | 769 | { |
761 | while (nsessions > 0) | 770 | while (nsessions > 0) |
762 | { | 771 | { |
763 | doneSession(getTe(), 0); | 772 | doneSession(getTe(), 0); |
764 | } | 773 | } |
765 | } | 774 | } |
766 | 775 | ||
767 | void | 776 | void |
768 | Konsole::historyDialog() | 777 | Konsole::historyDialog() |
769 | { | 778 | { |
770 | QDialog *d = new QDialog ( this, "histdlg", true ); | 779 | QDialog *d = new QDialog ( this, "histdlg", true ); |
771 | // d-> setCaption ( tr( "History" )); | 780 | // d-> setCaption ( tr( "History" )); |
772 | 781 | ||
773 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | 782 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); |
774 | 783 | ||
775 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | 784 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); |
776 | lay-> addWidget ( l ); | 785 | lay-> addWidget ( l ); |
777 | 786 | ||
778 | Config cfg( "Konsole" ); | 787 | Config cfg( "Konsole" ); |
779 | cfg.setGroup("History"); | 788 | cfg.setGroup("History"); |
780 | int hist = cfg.readNumEntry("history_lines",300); | 789 | int hist = cfg.readNumEntry("history_lines",300); |
781 | int avg_line = cfg.readNumEntry("avg_line_length",60); | 790 | int avg_line = cfg.readNumEntry("avg_line_length",60); |
782 | 791 | ||
783 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | 792 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); |
784 | spin-> setValue ( hist ); | 793 | spin-> setValue ( hist ); |
785 | spin-> setWrapping ( true ); | 794 | spin-> setWrapping ( true ); |
786 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | 795 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); |
787 | lay-> addWidget ( spin ); | 796 | lay-> addWidget ( spin ); |
788 | 797 | ||
789 | if ( d-> exec ( ) == QDialog::Accepted ) | 798 | if ( d-> exec ( ) == QDialog::Accepted ) |
790 | { | 799 | { |
791 | cfg.writeEntry("history_lines", spin->value()); | 800 | cfg.writeEntry("history_lines", spin->value()); |
792 | cfg.writeEntry("avg_line_length", avg_line); | 801 | cfg.writeEntry("avg_line_length", avg_line); |
793 | if (getTe() != NULL) | 802 | if (getTe() != NULL) |
794 | { | 803 | { |
795 | getTe()->currentSession->setHistory(true); | 804 | getTe()->currentSession->setHistory(true); |
796 | } | 805 | } |
797 | } | 806 | } |
798 | 807 | ||
799 | delete d; | 808 | delete d; |
800 | } | 809 | } |
801 | 810 | ||
802 | 811 | ||
803 | void Konsole::cycleZoom() | 812 | void Konsole::cycleZoom() |
804 | { | 813 | { |
805 | TEWidget* te = getTe(); | 814 | TEWidget* te = getTe(); |
806 | QFont font = te->getVTFont(); | 815 | QFont font = te->getVTFont(); |
807 | int size = font.pointSize(); | 816 | int size = font.pointSize(); |
808 | changeFontSize(1); | 817 | changeFontSize(1); |
809 | font = te->getVTFont(); | 818 | font = te->getVTFont(); |
810 | if (font.pointSize() <= size) | 819 | if (font.pointSize() <= size) |
811 | { | 820 | { |
812 | do | 821 | do |
813 | { | 822 | { |
814 | font = te->getVTFont(); | 823 | font = te->getVTFont(); |
815 | size = font.pointSize(); | 824 | size = font.pointSize(); |
816 | changeFontSize(-1); | 825 | changeFontSize(-1); |
817 | font = te->getVTFont(); | 826 | font = te->getVTFont(); |
818 | } | 827 | } |
819 | while (font.pointSize() < size); | 828 | while (font.pointSize() < size); |
820 | } | 829 | } |
821 | } | 830 | } |
822 | 831 | ||
823 | void Konsole::changeFontSize(int delta) | 832 | void Konsole::changeFontSize(int delta) |
824 | { | 833 | { |
825 | // printf("delta font size %d\n", delta); | 834 | // printf("delta font size %d\n", delta); |
826 | TEWidget* te = getTe(); | 835 | TEWidget* te = getTe(); |
827 | QFont font = te->getVTFont(); | 836 | QFont font = te->getVTFont(); |
828 | int size = font.pointSize(); | 837 | int size = font.pointSize(); |
829 | int closest = delta > 0? 10000 : -10000; | 838 | int closest = delta > 0? 10000 : -10000; |
830 | int closest_font = -1; | 839 | int closest_font = -1; |
831 | for(uint i = 0; i < fonts.count(); i++) | 840 | for(uint i = 0; i < fonts.count(); i++) |
832 | { | 841 | { |
833 | if (fonts.at(i)->getFont() == font) | 842 | if (fonts.at(i)->getFont() == font) |
834 | { | 843 | { |
835 | if (delta > 0) | 844 | if (delta > 0) |
836 | { | 845 | { |
837 | if (i+1 < fonts.count() | 846 | if (i+1 < fonts.count() |
838 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 847 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
839 | { | 848 | { |
840 | setFont(i+1); | 849 | setFont(i+1); |
841 | printf("font %d\n", i+1); | 850 | printf("font %d\n", i+1); |
842 | return; | 851 | return; |
843 | } | 852 | } |
844 | } | 853 | } |
845 | else if (delta < 0) | 854 | else if (delta < 0) |
846 | { | 855 | { |
847 | if (i > 0 | 856 | if (i > 0 |
848 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | 857 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) |
849 | { | 858 | { |
850 | setFont(i-1); | 859 | setFont(i-1); |
851 | printf("font %d\n", i-1); | 860 | printf("font %d\n", i-1); |
852 | return; | 861 | return; |
853 | } | 862 | } |
854 | } | 863 | } |
855 | } | 864 | } |
856 | int fsize = fonts.at(i)->getSize(); | 865 | int fsize = fonts.at(i)->getSize(); |
857 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | 866 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); |
858 | if ((delta > 0 && fsize > size && fsize < closest) | 867 | if ((delta > 0 && fsize > size && fsize < closest) |
859 | || (delta < 0 && fsize < size && fsize > closest)) | 868 | || (delta < 0 && fsize < size && fsize > closest)) |
860 | { | 869 | { |
861 | closest = fsize; | 870 | closest = fsize; |
862 | closest_font = i; | 871 | closest_font = i; |
863 | } | 872 | } |
864 | } | 873 | } |
865 | if (closest_font >= 0) | 874 | if (closest_font >= 0) |
866 | { | 875 | { |
867 | printf("font closest %d (%d)\n", closest_font, closest); | 876 | printf("font closest %d (%d)\n", closest_font, closest); |
868 | setFont(closest_font); | 877 | setFont(closest_font); |
869 | } | 878 | } |
870 | } | 879 | } |
871 | 880 | ||
872 | int Konsole::findFont(const QString& name, int size, bool exactMatch) | 881 | int Konsole::findFont(const QString& name, int size, bool exactMatch) |
873 | { | 882 | { |
874 | for(uint i = 0; i < fonts.count(); i++) | 883 | for(uint i = 0; i < fonts.count(); i++) |
875 | { | 884 | { |
876 | if (fonts.at(i)->getName() == name | 885 | if (fonts.at(i)->getName() == name |
877 | && fonts.at(i)->getSize() == size) | 886 | && fonts.at(i)->getSize() == size) |
878 | { | 887 | { |
879 | return(i); | 888 | return(i); |
880 | } | 889 | } |
881 | } | 890 | } |
882 | if (exactMatch) | 891 | if (exactMatch) |
883 | { | 892 | { |
884 | return(-1); | 893 | return(-1); |
885 | } | 894 | } |
886 | for(uint i = 0; i < fonts.count(); i++) | 895 | for(uint i = 0; i < fonts.count(); i++) |
887 | { | 896 | { |
888 | if (fonts.at(i)->getSize() == size) | 897 | if (fonts.at(i)->getSize() == size) |
889 | { | 898 | { |
890 | return(i); | 899 | return(i); |
891 | } | 900 | } |
892 | } | 901 | } |
893 | return(-1); | 902 | return(-1); |
894 | } | 903 | } |
895 | 904 | ||
896 | void Konsole::setFont(int f) | 905 | void Konsole::setFont(int f) |
897 | { | 906 | { |
898 | VTFont* font = fonts.at(f); | 907 | VTFont* font = fonts.at(f); |
899 | if (font) | 908 | if (font) |
900 | { | 909 | { |
901 | TEWidget* te = getTe(); | 910 | TEWidget* te = getTe(); |
902 | if (te != 0) | 911 | if (te != 0) |
903 | { | 912 | { |
904 | te->setVTFont(font->getFont()); | 913 | te->setVTFont(font->getFont()); |
905 | } | 914 | } |
906 | cfont = f; | 915 | cfont = f; |
907 | 916 | ||
908 | int familyNum = font->getFamilyNum(); | 917 | int familyNum = font->getFamilyNum(); |
909 | int size = font->getSize(); | 918 | int size = font->getSize(); |
910 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | 919 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, |
911 | fontList->count()); | 920 | fontList->count()); |
912 | for(int i = 0; i < (int)fontList->count(); i++) | 921 | for(int i = 0; i < (int)fontList->count(); i++) |
913 | { | 922 | { |
914 | fontList->setItemChecked(i + 1000, i == familyNum); | 923 | fontList->setItemChecked(i + 1000, i == familyNum); |
915 | } | 924 | } |
916 | for(int i = 0; i < (int)fonts.count(); i++) | 925 | for(int i = 0; i < (int)fonts.count(); i++) |
917 | { | 926 | { |
918 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | 927 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum |
919 | && fonts.at(i)->getSize() == size); | 928 | && fonts.at(i)->getSize() == size); |
920 | } | 929 | } |
921 | Config cfg( "Konsole" ); | 930 | Config cfg( "Konsole" ); |
922 | cfg.setGroup("Font"); | 931 | cfg.setGroup("Font"); |
923 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | 932 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); |
924 | if (tab->currentPageIndex() == 0) | 933 | if (tab->currentPageIndex() == 0) |
925 | { | 934 | { |
926 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | 935 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); |
927 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | 936 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); |
928 | } | 937 | } |
929 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | 938 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); |
930 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | 939 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); |
931 | } | 940 | } |
932 | } | 941 | } |
933 | 942 | ||
934 | #if 0 | 943 | #if 0 |
935 | void Konsole::fontChanged(int f) | 944 | void Konsole::fontChanged(int f) |
936 | { | 945 | { |
937 | VTFont* font = fonts.at(f); | 946 | VTFont* font = fonts.at(f); |
938 | if (font != 0) | 947 | if (font != 0) |
939 | { | 948 | { |
940 | for(uint i = 0; i < fonts.count(); i++) | 949 | for(uint i = 0; i < fonts.count(); i++) |
941 | { | 950 | { |
942 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 951 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
943 | } | 952 | } |
944 | 953 | ||
945 | cfont = f; | 954 | cfont = f; |
946 | 955 | ||
947 | TEWidget* te = getTe(); | 956 | TEWidget* te = getTe(); |
948 | if (te != 0) | 957 | if (te != 0) |
949 | { | 958 | { |
950 | te->setVTFont(font->getFont()); | 959 | te->setVTFont(font->getFont()); |
951 | } | 960 | } |
952 | } | 961 | } |
953 | } | 962 | } |
954 | #endif | 963 | #endif |
955 | 964 | ||
956 | 965 | ||
957 | void Konsole::enterCommand(int c) | 966 | void Konsole::enterCommand(int c) |
958 | { | 967 | { |
959 | TEWidget* te = getTe(); | 968 | TEWidget* te = getTe(); |
960 | if (te != 0) | 969 | if (te != 0) |
961 | { | 970 | { |
962 | if(!commonCombo->editable()) | 971 | if(!commonCombo->editable()) |
963 | { | 972 | { |
964 | QString text = commonCombo->text(c); //commonCmds[c]; | 973 | QString text = commonCombo->text(c); //commonCmds[c]; |
965 | te->emitText(text); | 974 | te->emitText(text); |
966 | } | 975 | } |
967 | else | 976 | else |
968 | { | 977 | { |
969 | changeCommand( commonCombo->text(c), c); | 978 | changeCommand( commonCombo->text(c), c); |
970 | } | 979 | } |
971 | } | 980 | } |
972 | } | 981 | } |
973 | 982 | ||
974 | void Konsole::hitEnter() | 983 | void Konsole::hitEnter() |
975 | { | 984 | { |
976 | TEWidget* te = getTe(); | 985 | TEWidget* te = getTe(); |
977 | if (te != 0) | 986 | if (te != 0) |
978 | { | 987 | { |
979 | te->emitText(QString("\r")); | 988 | te->emitText(QString("\r")); |
980 | } | 989 | } |
981 | } | 990 | } |
982 | 991 | ||
983 | void Konsole::hitSpace() | 992 | void Konsole::hitSpace() |
984 | { | 993 | { |
985 | TEWidget* te = getTe(); | 994 | TEWidget* te = getTe(); |
986 | if (te != 0) | 995 | if (te != 0) |
987 | { | 996 | { |
988 | te->emitText(QString(" ")); | 997 | te->emitText(QString(" ")); |
989 | } | 998 | } |
990 | } | 999 | } |
991 | 1000 | ||
992 | void Konsole::hitTab() | 1001 | void Konsole::hitTab() |
993 | { | 1002 | { |
994 | TEWidget* te = getTe(); | 1003 | TEWidget* te = getTe(); |
995 | if (te != 0) | 1004 | if (te != 0) |
996 | { | 1005 | { |
997 | te->emitText(QString("\t")); | 1006 | te->emitText(QString("\t")); |
998 | } | 1007 | } |
999 | } | 1008 | } |
1000 | 1009 | ||
1001 | void Konsole::hitPaste() | 1010 | void Konsole::hitPaste() |
1002 | { | 1011 | { |
1003 | TEWidget* te = getTe(); | 1012 | TEWidget* te = getTe(); |
1004 | if (te != 0) | 1013 | if (te != 0) |
1005 | { | 1014 | { |
1006 | te->pasteClipboard(); | 1015 | te->pasteClipboard(); |
1007 | } | 1016 | } |
1008 | } | 1017 | } |
1009 | 1018 | ||
1010 | void Konsole::hitUp() | 1019 | void Konsole::hitUp() |
1011 | { | 1020 | { |
1012 | TEWidget* te = getTe(); | 1021 | TEWidget* te = getTe(); |
1013 | if (te != 0) | 1022 | if (te != 0) |
1014 | { | 1023 | { |
1015 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1024 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1016 | QApplication::sendEvent( te, &ke ); | 1025 | QApplication::sendEvent( te, &ke ); |
1017 | } | 1026 | } |
1018 | } | 1027 | } |
1019 | 1028 | ||
1020 | void Konsole::hitDown() | 1029 | void Konsole::hitDown() |
1021 | { | 1030 | { |
1022 | TEWidget* te = getTe(); | 1031 | TEWidget* te = getTe(); |
1023 | if (te != 0) | 1032 | if (te != 0) |
1024 | { | 1033 | { |
1025 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1034 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1026 | QApplication::sendEvent( te, &ke ); | 1035 | QApplication::sendEvent( te, &ke ); |
1027 | } | 1036 | } |
1028 | } | 1037 | } |
1029 | 1038 | ||
1030 | /** | 1039 | /** |
1031 | This function calculates the size of the external widget | 1040 | This function calculates the size of the external widget |
1032 | needed for the internal widget to be | 1041 | needed for the internal widget to be |
1033 | */ | 1042 | */ |
1034 | QSize Konsole::calcSize(int columns, int lines) | 1043 | QSize Konsole::calcSize(int columns, int lines) |
1035 | { | 1044 | { |
1036 | TEWidget* te = getTe(); | 1045 | TEWidget* te = getTe(); |
1037 | if (te != 0) | 1046 | if (te != 0) |
1038 | { | 1047 | { |
1039 | QSize size = te->calcSize(columns, lines); | 1048 | QSize size = te->calcSize(columns, lines); |
1040 | return size; | 1049 | return size; |
1041 | } | 1050 | } |
1042 | else | 1051 | else |
1043 | { | 1052 | { |
1044 | QSize size; | 1053 | QSize size; |
1045 | return size; | 1054 | return size; |
1046 | } | 1055 | } |
1047 | } | 1056 | } |
1048 | 1057 | ||
1049 | /** | 1058 | /** |
1050 | sets application window to a size based on columns X lines of the te | 1059 | sets application window to a size based on columns X lines of the te |
1051 | guest widget. Call with (0,0) for setting default size. | 1060 | guest widget. Call with (0,0) for setting default size. |
1052 | */ | 1061 | */ |
1053 | 1062 | ||
1054 | void Konsole::setColLin(int columns, int lines) | 1063 | void Konsole::setColLin(int columns, int lines) |
1055 | { | 1064 | { |
1056 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; | 1065 | odebug << "konsole::setColLin:: Columns " << columns << "" << oendl; |
1057 | 1066 | ||
1058 | if ((columns==0) || (lines==0)) | 1067 | if ((columns==0) || (lines==0)) |
1059 | { | 1068 | { |
1060 | if (defaultSize.isEmpty()) // not in config file : set default value | 1069 | if (defaultSize.isEmpty()) // not in config file : set default value |
1061 | { | 1070 | { |
1062 | defaultSize = calcSize(80,24); | 1071 | defaultSize = calcSize(80,24); |
1063 | // notifySize(24,80); // set menu items (strange arg order !) | 1072 | // notifySize(24,80); // set menu items (strange arg order !) |
1064 | } | 1073 | } |
1065 | resize(defaultSize); | 1074 | resize(defaultSize); |
1066 | } | 1075 | } |
1067 | else | 1076 | else |
1068 | { | 1077 | { |
1069 | resize(calcSize(columns, lines)); | 1078 | resize(calcSize(columns, lines)); |
1070 | // notifySize(lines,columns); // set menu items (strange arg order !) | 1079 | // notifySize(lines,columns); // set menu items (strange arg order !) |
1071 | } | 1080 | } |
1072 | } | 1081 | } |
1073 | 1082 | ||
1074 | /* | 1083 | /* |
1075 | void Konsole::setFont(int fontno) | 1084 | void Konsole::setFont(int fontno) |
1076 | { | 1085 | { |
1077 | QFont f; | 1086 | QFont f; |
1078 | if (fontno == 0) | 1087 | if (fontno == 0) |
1079 | f = defaultFont = QFont( "Helvetica", 12 ); | 1088 | f = defaultFont = QFont( "Helvetica", 12 ); |
1080 | else | 1089 | else |
1081 | if (fonts[fontno][0] == '-') | 1090 | if (fonts[fontno][0] == '-') |
1082 | f.setRawName( fonts[fontno] ); | 1091 | f.setRawName( fonts[fontno] ); |
1083 | else | 1092 | else |
1084 | { | 1093 | { |
1085 | f.setFamily(fonts[fontno]); | 1094 | f.setFamily(fonts[fontno]); |
1086 | f.setRawMode( TRUE ); | 1095 | f.setRawMode( TRUE ); |
1087 | } | 1096 | } |
1088 | if ( !f.exactMatch() && fontno != 0) | 1097 | if ( !f.exactMatch() && fontno != 0) |
1089 | { | 1098 | { |
1090 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); | 1099 | QString msg = i18n("Font `%1' not found.\nCheck README.linux.console for help.").arg(fonts[fontno]); |
1091 | QMessageBox(this, msg); | 1100 | QMessageBox(this, msg); |
1092 | return; | 1101 | return; |
1093 | } | 1102 | } |
1094 | if (se) se->setFontNo(fontno); | 1103 | if (se) se->setFontNo(fontno); |
1095 | te->setVTFont(f); | 1104 | te->setVTFont(f); |
1096 | n_font = fontno; | 1105 | n_font = fontno; |
1097 | } | 1106 | } |
1098 | */ | 1107 | */ |
1099 | 1108 | ||
1100 | // --| color selection |------------------------------------------------------- | 1109 | // --| color selection |------------------------------------------------------- |
1101 | 1110 | ||
1102 | void Konsole::changeColumns(int /*columns*/) | 1111 | void Konsole::changeColumns(int /*columns*/) |
1103 | { //FIXME this seems to cause silliness when reset command is executed | 1112 | { //FIXME this seems to cause silliness when reset command is executed |
1104 | // odebug << "change columns" << oendl; | 1113 | // odebug << "change columns" << oendl; |
1105 | // TEWidget* te = getTe(); | 1114 | // TEWidget* te = getTe(); |
1106 | // if (te != 0) { | 1115 | // if (te != 0) { |
1107 | // setColLin(columns,te->Lines()); | 1116 | // setColLin(columns,te->Lines()); |
1108 | // te->update(); | 1117 | // te->update(); |
1109 | // } | 1118 | // } |
1110 | } | 1119 | } |
1111 | 1120 | ||
1112 | //FIXME: If a child dies during session swap, | 1121 | //FIXME: If a child dies during session swap, |
1113 | // this routine might be called before | 1122 | // this routine might be called before |
1114 | // session swap is completed. | 1123 | // session swap is completed. |
1115 | 1124 | ||
1116 | void Konsole::doneSession(TEWidget* te, int ) | 1125 | void Konsole::doneSession(TEWidget* te, int ) |
1117 | { | 1126 | { |
1118 | // TEWidget *te = NULL; | 1127 | // TEWidget *te = NULL; |
1119 | // if (sess->currentSession == tab->currentPage()) { | 1128 | // if (sess->currentSession == tab->currentPage()) { |
1120 | // printf("done current session\n"); | 1129 | // printf("done current session\n"); |
1121 | // te = getTe(); | 1130 | // te = getTe(); |
1122 | // } else { | 1131 | // } else { |
1123 | // int currentPage = tab->currentPageIndex(); | 1132 | // int currentPage = tab->currentPageIndex(); |
1124 | // printf("done not current session\n"); | 1133 | // printf("done not current session\n"); |
1125 | // for(int i = 0; i < nsessions; i++) { | 1134 | // for(int i = 0; i < nsessions; i++) { |
1126 | // tab->setCurrentPage(i); | 1135 | // tab->setCurrentPage(i); |
1127 | // printf("find session %d tab page %x session %x\n", | 1136 | // printf("find session %d tab page %x session %x\n", |
1128 | // i, tab->currentPage(), sess->currentSession); | 1137 | // i, tab->currentPage(), sess->currentSession); |
1129 | // if (tab->currentPage() == sess->currentSession) { | 1138 | // if (tab->currentPage() == sess->currentSession) { |
1130 | // printf("found session %d\n", i); | 1139 | // printf("found session %d\n", i); |
1131 | // te = tab->currentPage(); | 1140 | // te = tab->currentPage(); |
1132 | // break; | 1141 | // break; |
1133 | // } | 1142 | // } |
1134 | // } | 1143 | // } |
1135 | // tab->setCurrentPage(currentPage); | 1144 | // tab->setCurrentPage(currentPage); |
1136 | // } | 1145 | // } |
1137 | if (te != 0) | 1146 | if (te != 0) |
1138 | { | 1147 | { |
1139 | te->currentSession->setConnect(FALSE); | 1148 | te->currentSession->setConnect(FALSE); |
1140 | tab->removeTab(te); | 1149 | tab->removeTab(te); |
1141 | delete te->currentSession; | 1150 | delete te->currentSession; |
1142 | delete te; | 1151 | delete te; |
1143 | sessionList->removeItem(nsessions); | 1152 | sessionList->removeItem(nsessions); |
1144 | nsessions--; | 1153 | nsessions--; |
1145 | } | 1154 | } |
1146 | if (nsessions == 0) | 1155 | if (nsessions == 0) |
1147 | { | 1156 | { |
1148 | close(); | 1157 | close(); |
1149 | } | 1158 | } |
1150 | } | 1159 | } |
1151 | 1160 | ||
1152 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) | 1161 | void Konsole::changeTitle(TEWidget* te, const QString& newTitle ) |
1153 | { | 1162 | { |
1154 | if (te == getTe()) | 1163 | if (te == getTe()) |
1155 | { | 1164 | { |
1156 | setCaption( newTitle + " - " + tr( "Konsole " ) ); | 1165 | setCaption( newTitle + " - " + tr( "Konsole " ) ); |
1157 | } | 1166 | } |
1158 | } | 1167 | } |
1159 | 1168 | ||
1160 | 1169 | ||
1161 | void Konsole::newSession() | 1170 | void Konsole::newSession() |
1162 | { | 1171 | { |
1163 | if(nsessions < 15) | 1172 | if(nsessions < 15) |
1164 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | 1173 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? |
1165 | TEWidget* te = new TEWidget(tab); | 1174 | TEWidget* te = new TEWidget(tab); |
1166 | Config cfg( "Konsole" ); | 1175 | Config cfg( "Konsole" ); |
1167 | cfg.setGroup("Menubar"); | 1176 | cfg.setGroup("Menubar"); |
1168 | 1177 | ||
1169 | // FIXME use more defaults from config file | 1178 | // FIXME use more defaults from config file |
1170 | te->useBeep=cfg.readBoolEntry("useBeep",0); | 1179 | te->useBeep=cfg.readBoolEntry("useBeep",0); |
1171 | 1180 | ||
1172 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1181 | // te->setBackgroundMode(PaletteBase); //we want transparent!! |
1173 | 1182 | ||
1174 | cfg.setGroup("Font"); | 1183 | cfg.setGroup("Font"); |
1175 | QString sn = "Session" + QString::number(nsessions+1); | 1184 | QString sn = "Session" + QString::number(nsessions+1); |
1176 | printf("read font session %s\n", sn.latin1()); | 1185 | printf("read font session %s\n", sn.latin1()); |
1177 | QString fontName = cfg.readEntry("FontName"+sn, | 1186 | QString fontName = cfg.readEntry("FontName"+sn, |
1178 | cfg.readEntry("FontName", | 1187 | cfg.readEntry("FontName", |
1179 | fonts.at(cfont)->getFamily())); | 1188 | fonts.at(cfont)->getFamily())); |
1180 | int fontSize = cfg.readNumEntry("FontSize"+sn, | 1189 | int fontSize = cfg.readNumEntry("FontSize"+sn, |
1181 | cfg.readNumEntry("FontSize", | 1190 | cfg.readNumEntry("FontSize", |
1182 | fonts.at(cfont)->getSize())); | 1191 | fonts.at(cfont)->getSize())); |
1183 | cfont = findFont(fontName, fontSize, false); | 1192 | cfont = findFont(fontName, fontSize, false); |
1184 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | 1193 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); |
1185 | if (cfont < 0) | 1194 | if (cfont < 0) |
1186 | cfont = 0; | 1195 | cfont = 0; |
1187 | te->setVTFont(fonts.at(cfont)->getFont()); | 1196 | te->setVTFont(fonts.at(cfont)->getFont()); |
1188 | 1197 | ||
1189 | tab->addTab(te); | 1198 | tab->addTab(te); |
1190 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1199 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
1191 | te->currentSession = se; | 1200 | te->currentSession = se; |
1192 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); | 1201 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1193 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, | 1202 | connect( se, SIGNAL(changeTitle(TEWidget*,const QString&)), this, |
1194 | SLOT(changeTitle(TEWidget*,const QString&)) ); | 1203 | SLOT(changeTitle(TEWidget*,const QString&)) ); |
1195 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | 1204 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); |
1196 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | 1205 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); |
1197 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | 1206 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); |
1198 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | 1207 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); |
1199 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | 1208 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); |
1200 | se->run(); | 1209 | se->run(); |
1201 | se->setConnect(TRUE); | 1210 | se->setConnect(TRUE); |
1202 | se->setHistory(b_scroll); | 1211 | se->setHistory(b_scroll); |
1203 | nsessions++; | 1212 | nsessions++; |
1204 | sessionList->insertItem(QString::number(nsessions), nsessions); | 1213 | sessionList->insertItem(QString::number(nsessions), nsessions); |
1205 | sessionListSelected(nsessions); | 1214 | sessionListSelected(nsessions); |
1206 | doWrap(); | 1215 | doWrap(); |
1207 | setColor(nsessions-1); | 1216 | setColor(nsessions-1); |
1208 | } | 1217 | } |
1209 | } | 1218 | } |
1210 | 1219 | ||
1211 | TEWidget* Konsole::getTe() | 1220 | TEWidget* Konsole::getTe() |
1212 | { | 1221 | { |
1213 | if (nsessions) | 1222 | if (nsessions) |
1214 | { | 1223 | { |
1215 | return (TEWidget *) tab->currentPage(); | 1224 | return (TEWidget *) tab->currentPage(); |
1216 | } | 1225 | } |
1217 | else | 1226 | else |
1218 | { | 1227 | { |
1219 | return 0; | 1228 | return 0; |
1220 | } | 1229 | } |
1221 | } | 1230 | } |
1222 | 1231 | ||
1223 | void Konsole::sessionListSelected(int id) | 1232 | void Konsole::sessionListSelected(int id) |
1224 | { | 1233 | { |
1225 | if (id < 0) | 1234 | if (id < 0) |
1226 | { | 1235 | { |
1227 | return; | 1236 | return; |
1228 | } | 1237 | } |
1229 | QString selected = sessionList->text(id); | 1238 | QString selected = sessionList->text(id); |
1230 | EKNumTabBar *tabBar = tab->getTabBar(); | 1239 | EKNumTabBar *tabBar = tab->getTabBar(); |
1231 | 1240 | ||
1232 | int n = 0; | 1241 | int n = 0; |
1233 | for(int i = 0; n < tabBar->count(); i++) | 1242 | for(int i = 0; n < tabBar->count(); i++) |
1234 | { | 1243 | { |
1235 | if (tabBar->tab(i)) | 1244 | if (tabBar->tab(i)) |
1236 | { | 1245 | { |
1237 | // printf("selected = %s tab %d = %s\n", selected.latin1(), | 1246 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
1238 | // i, tabBar->tab(i)->text().latin1()); | 1247 | // i, tabBar->tab(i)->text().latin1()); |
1239 | if (tabBar->tab(i)->text() == selected) | 1248 | if (tabBar->tab(i)->text() == selected) |
1240 | { | 1249 | { |
1241 | tab->setCurrentPage(i); | 1250 | tab->setCurrentPage(i); |
1242 | break; | 1251 | break; |
1243 | } | 1252 | } |
1244 | n++; | 1253 | n++; |
1245 | } | 1254 | } |
1246 | } | 1255 | } |
1247 | } | 1256 | } |
1248 | 1257 | ||
1249 | 1258 | ||
1250 | void Konsole::changeSession(int delta) | 1259 | void Konsole::changeSession(int delta) |
1251 | { | 1260 | { |
1252 | printf("delta session %d\n", delta); | 1261 | printf("delta session %d\n", delta); |
1253 | QTabBar *tabBar = tab->getTabBar(); | 1262 | QTabBar *tabBar = tab->getTabBar(); |
1254 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | 1263 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; |
1255 | i += delta; | 1264 | i += delta; |
1256 | if (i < 0) | 1265 | if (i < 0) |
1257 | i += tabBar->count(); | 1266 | i += tabBar->count(); |
1258 | if (i >= tabBar->count()) | 1267 | if (i >= tabBar->count()) |
1259 | i -= tabBar->count(); | 1268 | i -= tabBar->count(); |
1260 | 1269 | ||
1261 | QString selected = QString::number(i+1); | 1270 | QString selected = QString::number(i+1); |
1262 | int n = 0; | 1271 | int n = 0; |
1263 | for(int i = 0; n < tabBar->count(); i++) | 1272 | for(int i = 0; n < tabBar->count(); i++) |
1264 | { | 1273 | { |
1265 | if (tabBar->tab(i)) | 1274 | if (tabBar->tab(i)) |
1266 | { | 1275 | { |
1267 | printf("selected = %s tab %d = %s\n", selected.latin1(), | 1276 | printf("selected = %s tab %d = %s\n", selected.latin1(), |
1268 | i, tabBar->tab(i)->text().latin1()); | 1277 | i, tabBar->tab(i)->text().latin1()); |
1269 | if (tabBar->tab(i)->text() == selected) | 1278 | if (tabBar->tab(i)->text() == selected) |
1270 | { | 1279 | { |
1271 | tab->setCurrentPage(i); | 1280 | tab->setCurrentPage(i); |
1272 | break; | 1281 | break; |
1273 | } | 1282 | } |
1274 | n++; | 1283 | n++; |
1275 | } | 1284 | } |
1276 | } | 1285 | } |
1277 | } | 1286 | } |
1278 | 1287 | ||
1279 | void Konsole::switchSession(QWidget* w) | 1288 | void Konsole::switchSession(QWidget* w) |
1280 | { | 1289 | { |
1281 | TEWidget* te = (TEWidget *) w; | 1290 | TEWidget* te = (TEWidget *) w; |
1282 | QFont teFnt = te->getVTFont(); | 1291 | QFont teFnt = te->getVTFont(); |
1283 | int familyNum = -1; | 1292 | int familyNum = -1; |
1284 | 1293 | ||
1285 | for(uint i = 0; i < fonts.count(); i++) | 1294 | for(uint i = 0; i < fonts.count(); i++) |
1286 | { | 1295 | { |
1287 | VTFont *fnt = fonts.at(i); | 1296 | VTFont *fnt = fonts.at(i); |
1288 | bool cf = fnt->getFont() == teFnt; | 1297 | bool cf = fnt->getFont() == teFnt; |
1289 | fontList->setItemChecked(i, cf); | 1298 | fontList->setItemChecked(i, cf); |
1290 | if (cf) | 1299 | if (cf) |
1291 | { | 1300 | { |
1292 | cfont = i; | 1301 | cfont = i; |
1293 | familyNum = fnt->getFamilyNum(); | 1302 | familyNum = fnt->getFamilyNum(); |
1294 | } | 1303 | } |
1295 | } | 1304 | } |
1296 | for(int i = 0; i < (int)fontList->count(); i++) | 1305 | for(int i = 0; i < (int)fontList->count(); i++) |
1297 | { | 1306 | { |
1298 | fontList->setItemChecked(i + 1000, i == familyNum); | 1307 | fontList->setItemChecked(i + 1000, i == familyNum); |
1299 | } | 1308 | } |
1300 | if (! te->currentSession->Title().isEmpty() ) | 1309 | if (! te->currentSession->Title().isEmpty() ) |
1301 | { | 1310 | { |
1302 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); | 1311 | setCaption( te->currentSession->Title() + " - " + tr( "Konsole" ) ); |
1303 | } | 1312 | } |
1304 | else | 1313 | else |
1305 | { | 1314 | { |
1306 | setCaption( tr( "Konsole" ) ); | 1315 | setCaption( tr( "Konsole" ) ); |
1307 | } | 1316 | } |
1308 | // colorMenuSelected(te->color_menu_item); | 1317 | // colorMenuSelected(te->color_menu_item); |
1309 | } | 1318 | } |
1310 | 1319 | ||
1311 | 1320 | ||
1312 | void Konsole::toggleFullScreen() | 1321 | void Konsole::toggleFullScreen() |
1313 | { | 1322 | { |
1314 | setFullScreen(! fullscreen); | 1323 | setFullScreen(! fullscreen); |
1315 | } | 1324 | } |
1316 | 1325 | ||
1317 | void Konsole::setFullScreen ( bool b ) | 1326 | void Konsole::setFullScreen ( bool b ) |
1318 | { | 1327 | { |
1319 | static QSize normalsize; | 1328 | static QSize normalsize; |
1320 | static bool listHidden; | 1329 | static bool listHidden; |
1321 | 1330 | ||
1322 | if (b == fullscreen) | 1331 | if (b == fullscreen) |
1323 | { | 1332 | { |
1324 | return; | 1333 | return; |
1325 | } | 1334 | } |
1326 | 1335 | ||
1327 | fullscreen = b; | 1336 | fullscreen = b; |
1328 | 1337 | ||
1329 | if ( b ) | 1338 | if ( b ) |
1330 | { | 1339 | { |
1331 | if ( !normalsize. isValid ( )) | 1340 | if ( !normalsize. isValid ( )) |
1332 | { | 1341 | { |
1333 | normalsize = size ( ); | 1342 | normalsize = size ( ); |
1334 | } | 1343 | } |
1335 | 1344 | ||
1336 | setFixedSize ( qApp-> desktop ( )-> size ( )); | 1345 | setFixedSize ( qApp-> desktop ( )-> size ( )); |
1337 | showNormal ( ); | 1346 | showNormal ( ); |
1338 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | 1347 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, |
1339 | QPoint ( 0, 0 )); | 1348 | QPoint ( 0, 0 )); |
1340 | showFullScreen ( ); | 1349 | showFullScreen ( ); |
1341 | 1350 | ||
1342 | menuToolBar->hide(); | 1351 | menuToolBar->hide(); |
1343 | toolBar->hide(); | 1352 | toolBar->hide(); |
1344 | listHidden = secondToolBar->isHidden(); | 1353 | listHidden = secondToolBar->isHidden(); |
1345 | secondToolBar->hide(); | 1354 | secondToolBar->hide(); |
1346 | // commonCombo->hide(); | 1355 | // commonCombo->hide(); |
1347 | tab->getTabBar()->hide(); | 1356 | tab->getTabBar()->hide(); |
1348 | tab->setMargin(tab->margin()); | 1357 | tab->setMargin(tab->margin()); |
1349 | 1358 | ||
1350 | if (show_fullscreen_msg) | 1359 | if (show_fullscreen_msg) |
1351 | { | 1360 | { |
1352 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | 1361 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, |
1353 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | 1362 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); |
1354 | fullscreen_msg->show(); | 1363 | fullscreen_msg->show(); |
1355 | fullscreen_timer->start(3000, true); | 1364 | fullscreen_timer->start(3000, true); |
1356 | show_fullscreen_msg = false; | 1365 | show_fullscreen_msg = false; |
1357 | } | 1366 | } |
1358 | } | 1367 | } |
1359 | else | 1368 | else |
1360 | { | 1369 | { |
1361 | showNormal ( ); | 1370 | showNormal ( ); |
1362 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); | 1371 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); |
1363 | resize ( normalsize ); | 1372 | resize ( normalsize ); |
1364 | showMaximized ( ); | 1373 | showMaximized ( ); |
1365 | normalsize = QSize ( ); | 1374 | normalsize = QSize ( ); |
1366 | 1375 | ||
1367 | menuToolBar->show(); | 1376 | menuToolBar->show(); |
1368 | toolBar->show(); | 1377 | toolBar->show(); |
1369 | if(! listHidden) | 1378 | if(! listHidden) |
1370 | { | 1379 | { |
1371 | secondToolBar->show(); | 1380 | secondToolBar->show(); |
1372 | } | 1381 | } |
1373 | // commonCombo->show(); | 1382 | // commonCombo->show(); |
1374 | menuToolBar->show(); | 1383 | menuToolBar->show(); |
1375 | if (tabPos != tm_hidden) | 1384 | if (tabPos != tm_hidden) |
1376 | { | 1385 | { |
1377 | tab->getTabBar()->show(); | 1386 | tab->getTabBar()->show(); |
1378 | } | 1387 | } |
1379 | } | 1388 | } |
1380 | tab->setMargin(tab->margin()); // cause setup to run | 1389 | tab->setMargin(tab->margin()); // cause setup to run |
1381 | } | 1390 | } |
1382 | 1391 | ||
1383 | 1392 | ||
1384 | void Konsole::fullscreenTimeout() | 1393 | void Konsole::fullscreenTimeout() |
1385 | { | 1394 | { |
1386 | fullscreen_msg->hide(); | 1395 | fullscreen_msg->hide(); |
1387 | } | 1396 | } |
1388 | 1397 | ||
1389 | void Konsole::colorMenuIsSelected(int iD) | 1398 | void Konsole::colorMenuIsSelected(int iD) |
1390 | { | 1399 | { |
1391 | fromMenu = TRUE; | 1400 | fromMenu = TRUE; |
1392 | colorMenuSelected(iD); | 1401 | colorMenuSelected(iD); |
1393 | } | 1402 | } |
1394 | 1403 | ||
1395 | /// ------------------------------- some new stuff by L.J. Potter | 1404 | /// ------------------------------- some new stuff by L.J. Potter |
1396 | 1405 | ||
1397 | 1406 | ||
1398 | void Konsole::colorMenuSelected(int iD) | 1407 | void Konsole::colorMenuSelected(int iD) |
1399 | { | 1408 | { |
1400 | // this is NOT pretty, elegant or anything else besides functional | 1409 | // this is NOT pretty, elegant or anything else besides functional |
1401 | // QString temp; | 1410 | // QString temp; |
1402 | // odebug << temp.sprintf("colormenu " << iD) << "" << oendl; | 1411 | // odebug << temp.sprintf("colormenu " << iD) << "" << oendl; |
1403 | 1412 | ||
1404 | TEWidget* te = getTe(); | 1413 | TEWidget* te = getTe(); |
1405 | Config cfg( "Konsole" ); | 1414 | Config cfg( "Konsole" ); |
1406 | cfg.setGroup("Colors"); | 1415 | cfg.setGroup("Colors"); |
1407 | 1416 | ||
1408 | ColorEntry m_table[TABLE_COLORS]; | 1417 | ColorEntry m_table[TABLE_COLORS]; |
1409 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1418 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1410 | 1419 | ||
1411 | int i; | 1420 | int i; |
1412 | 1421 | ||
1413 | // te->color_menu_item = iD; | 1422 | // te->color_menu_item = iD; |
1414 | 1423 | ||
1415 | colorMenu->setItemChecked(cm_ab,FALSE); | 1424 | colorMenu->setItemChecked(cm_ab,FALSE); |
1416 | colorMenu->setItemChecked(cm_bb,FALSE); | 1425 | colorMenu->setItemChecked(cm_bb,FALSE); |
1417 | colorMenu->setItemChecked(cm_wc,FALSE); | 1426 | colorMenu->setItemChecked(cm_wc,FALSE); |
1418 | colorMenu->setItemChecked(cm_cw,FALSE); | 1427 | colorMenu->setItemChecked(cm_cw,FALSE); |
1419 | colorMenu->setItemChecked(cm_mb,FALSE); | 1428 | colorMenu->setItemChecked(cm_mb,FALSE); |
1420 | colorMenu->setItemChecked(cm_bm,FALSE); | 1429 | colorMenu->setItemChecked(cm_bm,FALSE); |
1421 | colorMenu->setItemChecked(cm_gy,FALSE); | 1430 | colorMenu->setItemChecked(cm_gy,FALSE); |
1422 | colorMenu->setItemChecked(cm_rb,FALSE); | 1431 | colorMenu->setItemChecked(cm_rb,FALSE); |
1423 | colorMenu->setItemChecked(cm_br,FALSE); | 1432 | colorMenu->setItemChecked(cm_br,FALSE); |
1424 | colorMenu->setItemChecked(cm_wb,FALSE); | 1433 | colorMenu->setItemChecked(cm_wb,FALSE); |
1425 | colorMenu->setItemChecked(cm_bw,FALSE); | 1434 | colorMenu->setItemChecked(cm_bw,FALSE); |
1426 | colorMenu->setItemChecked(cm_gb,FALSE); | 1435 | colorMenu->setItemChecked(cm_gb,FALSE); |
1427 | 1436 | ||
1428 | if(iD==cm_default) | 1437 | if(iD==cm_default) |
1429 | { // default default | 1438 | { // default default |
1430 | printf("default colors\n"); | 1439 | printf("default colors\n"); |
1431 | for (i = 0; i < TABLE_COLORS; i++) | 1440 | for (i = 0; i < TABLE_COLORS; i++) |
1432 | { | 1441 | { |
1433 | m_table[i].color = defaultCt[i].color; | 1442 | m_table[i].color = defaultCt[i].color; |
1434 | if(i==1 || i == 11) | 1443 | if(i==1 || i == 11) |
1435 | m_table[i].transparent=1; | 1444 | m_table[i].transparent=1; |
1436 | colorMenu->setItemChecked(cm_default,TRUE); | 1445 | colorMenu->setItemChecked(cm_default,TRUE); |
1437 | } | 1446 | } |
1438 | te->setColorTable(m_table); | 1447 | te->setColorTable(m_table); |
1439 | } | 1448 | } |
1440 | if(iD==cm_gb) | 1449 | if(iD==cm_gb) |
1441 | { // green black | 1450 | { // green black |
1442 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | 1451 | foreground.setRgb(100,255,100); // (0x18,255,0x18); |
1443 | background.setRgb(0x00,0x00,0x00); | 1452 | background.setRgb(0x00,0x00,0x00); |
1444 | colorMenu->setItemChecked(cm_gb,TRUE); | 1453 | colorMenu->setItemChecked(cm_gb,TRUE); |
1445 | } | 1454 | } |
1446 | if(iD==cm_bw) | 1455 | if(iD==cm_bw) |
1447 | { // black white | 1456 | { // black white |
1448 | foreground.setRgb(0x00,0x00,0x00); | 1457 | foreground.setRgb(0x00,0x00,0x00); |
1449 | background.setRgb(0xFF,0xFF,0xFF); | 1458 | background.setRgb(0xFF,0xFF,0xFF); |
1450 | colorMenu->setItemChecked(cm_bw,TRUE); | 1459 | colorMenu->setItemChecked(cm_bw,TRUE); |
1451 | } | 1460 | } |
1452 | if(iD==cm_wb) | 1461 | if(iD==cm_wb) |
1453 | { // white black | 1462 | { // white black |
1454 | foreground.setRgb(0xFF,0xFF,0xFF); | 1463 | foreground.setRgb(0xFF,0xFF,0xFF); |
1455 | background.setRgb(0x00,0x00,0x00); | 1464 | background.setRgb(0x00,0x00,0x00); |
1456 | colorMenu->setItemChecked(cm_wb,TRUE); | 1465 | colorMenu->setItemChecked(cm_wb,TRUE); |
1457 | } | 1466 | } |
1458 | if(iD==cm_br) | 1467 | if(iD==cm_br) |
1459 | {// Black, Red | 1468 | {// Black, Red |
1460 | foreground.setRgb(0x00,0x00,0x00); | 1469 | foreground.setRgb(0x00,0x00,0x00); |
1461 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | 1470 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); |
1462 | colorMenu->setItemChecked(cm_br,TRUE); | 1471 | colorMenu->setItemChecked(cm_br,TRUE); |
1463 | } | 1472 | } |
1464 | if(iD==cm_rb) | 1473 | if(iD==cm_rb) |
1465 | {// Red, Black | 1474 | {// Red, Black |
1466 | foreground.setRgb(255,85,85); | 1475 | foreground.setRgb(255,85,85); |
1467 | background.setRgb(0x00,0x00,0x00); | 1476 | background.setRgb(0x00,0x00,0x00); |
1468 | colorMenu->setItemChecked(cm_rb,TRUE); | 1477 | colorMenu->setItemChecked(cm_rb,TRUE); |
1469 | } | 1478 | } |
1470 | if(iD==cm_gy) | 1479 | if(iD==cm_gy) |
1471 | {// Green, Yellow - is ugly | 1480 | {// Green, Yellow - is ugly |
1472 | // foreground.setRgb(0x18,0xB2,0x18); | 1481 | // foreground.setRgb(0x18,0xB2,0x18); |
1473 | foreground.setRgb(15,115,0); | 1482 | foreground.setRgb(15,115,0); |
1474 | // background.setRgb(0xB2,0x68,0x18); | 1483 | // background.setRgb(0xB2,0x68,0x18); |
1475 | background.setRgb(255,255,0); | 1484 | background.setRgb(255,255,0); |
1476 | colorMenu->setItemChecked(cm_gy,TRUE); | 1485 | colorMenu->setItemChecked(cm_gy,TRUE); |
1477 | } | 1486 | } |
1478 | if(iD==cm_bm) | 1487 | if(iD==cm_bm) |
1479 | {// Blue, Magenta | 1488 | {// Blue, Magenta |
1480 | foreground.setRgb(3,24,132); | 1489 | foreground.setRgb(3,24,132); |
1481 | background.setRgb(225,2,255); | 1490 | background.setRgb(225,2,255); |
1482 | colorMenu->setItemChecked(cm_bm,TRUE); | 1491 | colorMenu->setItemChecked(cm_bm,TRUE); |
1483 | } | 1492 | } |
1484 | if(iD==cm_mb) | 1493 | if(iD==cm_mb) |
1485 | {// Magenta, Blue | 1494 | {// Magenta, Blue |
1486 | foreground.setRgb(225,2,255); | 1495 | foreground.setRgb(225,2,255); |
1487 | background.setRgb(3,24,132); | 1496 | background.setRgb(3,24,132); |
1488 | colorMenu->setItemChecked(cm_mb,TRUE); | 1497 | colorMenu->setItemChecked(cm_mb,TRUE); |
1489 | } | 1498 | } |
1490 | if(iD==cm_cw) | 1499 | if(iD==cm_cw) |
1491 | {// Cyan, White | 1500 | {// Cyan, White |
1492 | foreground.setRgb(8,91,129); | 1501 | foreground.setRgb(8,91,129); |
1493 | background.setRgb(0xFF,0xFF,0xFF); | 1502 | background.setRgb(0xFF,0xFF,0xFF); |
1494 | colorMenu->setItemChecked(cm_cw,TRUE); | 1503 | colorMenu->setItemChecked(cm_cw,TRUE); |
1495 | } | 1504 | } |
1496 | if(iD==cm_wc) | 1505 | if(iD==cm_wc) |
1497 | {// White, Cyan | 1506 | {// White, Cyan |
1498 | background.setRgb(8,91,129); | 1507 | background.setRgb(8,91,129); |
1499 | foreground.setRgb(0xFF,0xFF,0xFF); | 1508 | foreground.setRgb(0xFF,0xFF,0xFF); |
1500 | colorMenu->setItemChecked(cm_wc,TRUE); | 1509 | colorMenu->setItemChecked(cm_wc,TRUE); |
1501 | } | 1510 | } |
1502 | if(iD==cm_bb) | 1511 | if(iD==cm_bb) |
1503 | {// Black, Blue | 1512 | {// Black, Blue |
1504 | background.setRgb(0x00,0x00,0x00); | 1513 | background.setRgb(0x00,0x00,0x00); |
1505 | foreground.setRgb(127,147,225); | 1514 | foreground.setRgb(127,147,225); |
1506 | colorMenu->setItemChecked(cm_bb,TRUE); | 1515 | colorMenu->setItemChecked(cm_bb,TRUE); |
1507 | } | 1516 | } |
1508 | if(iD==cm_ab) | 1517 | if(iD==cm_ab) |
1509 | {// Black, Gold | 1518 | {// Black, Gold |
1510 | background.setRgb(0x00,0x00,0x00); | 1519 | background.setRgb(0x00,0x00,0x00); |
1511 | foreground.setRgb(255,215,105); | 1520 | foreground.setRgb(255,215,105); |
1512 | colorMenu->setItemChecked(cm_ab,TRUE); | 1521 | colorMenu->setItemChecked(cm_ab,TRUE); |
1513 | } | 1522 | } |
1514 | #ifdef QT_QWS_OPIE | 1523 | #ifdef QT_QWS_OPIE |
1515 | if(iD==-19) | 1524 | if(iD==-19) |
1516 | { | 1525 | { |
1517 | // Custom | 1526 | // Custom |
1518 | odebug << "do custom" << oendl; | 1527 | odebug << "do custom" << oendl; |
1519 | if(fromMenu) | 1528 | if(fromMenu) |
1520 | { | 1529 | { |
1521 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); | 1530 | Opie::OColorPopupMenu* penColorPopupMenu = new Opie::OColorPopupMenu(Qt::black, this, "foreground color"); |
1522 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1531 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
1523 | SLOT(changeForegroundColor(const QColor&))); | 1532 | SLOT(changeForegroundColor(const QColor&))); |
1524 | penColorPopupMenu->exec(); | 1533 | penColorPopupMenu->exec(); |
1525 | } | 1534 | } |
1526 | if(!fromMenu) | 1535 | if(!fromMenu) |
1527 | { | 1536 | { |
1528 | foreground.setNamedColor(cfg.readEntry("foreground","")); | 1537 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
1529 | background.setNamedColor(cfg.readEntry("background","")); | 1538 | background.setNamedColor(cfg.readEntry("background","")); |
1530 | } | 1539 | } |
1531 | fromMenu=FALSE; | 1540 | fromMenu=FALSE; |
1532 | colorMenu->setItemChecked(-19,TRUE); | 1541 | colorMenu->setItemChecked(-19,TRUE); |
1533 | } | 1542 | } |
1534 | #endif | 1543 | #endif |
1535 | 1544 | ||
1536 | lastSelectedMenu = iD; | 1545 | lastSelectedMenu = iD; |
1537 | 1546 | ||
1538 | setColors(foreground, background); | 1547 | setColors(foreground, background); |
1539 | 1548 | ||
1540 | QTabBar *tabBar = tab->getTabBar(); | 1549 | QTabBar *tabBar = tab->getTabBar(); |
1541 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | 1550 | QString ss = QString("Session%1").arg(tabBar->currentTab()); |
1542 | // printf("current tab = %d\n", tabBar->currentTab()); | 1551 | // printf("current tab = %d\n", tabBar->currentTab()); |
1543 | 1552 | ||
1544 | if (tabBar->currentTab() == 0) | 1553 | if (tabBar->currentTab() == 0) |
1545 | { | 1554 | { |
1546 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | 1555 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); |
1547 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | 1556 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); |
1548 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | 1557 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); |
1549 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | 1558 | cfg.writeEntry("backgroundRed",QString::number(background.red())); |
1550 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | 1559 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); |
1551 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | 1560 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); |
1552 | } | 1561 | } |
1553 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | 1562 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); |
1554 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | 1563 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); |
1555 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | 1564 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); |
1556 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | 1565 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); |
1557 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | 1566 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); |
1558 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | 1567 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); |
1559 | 1568 | ||
1560 | update(); | 1569 | update(); |
1561 | } | 1570 | } |
1562 | 1571 | ||
1563 | void Konsole::setColors(QColor foreground, QColor background) | 1572 | void Konsole::setColors(QColor foreground, QColor background) |
1564 | { | 1573 | { |
1565 | int i; | 1574 | int i; |
1566 | ColorEntry m_table[TABLE_COLORS]; | 1575 | ColorEntry m_table[TABLE_COLORS]; |
1567 | TEWidget* te = getTe(); | 1576 | TEWidget* te = getTe(); |
1568 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1577 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
1569 | 1578 | ||
1570 | for (i = 0; i < TABLE_COLORS; i++) | 1579 | for (i = 0; i < TABLE_COLORS; i++) |
1571 | { | 1580 | { |
1572 | if(i==0 || i == 10) | 1581 | if(i==0 || i == 10) |
1573 | { | 1582 | { |
1574 | m_table[i].color = foreground; | 1583 | m_table[i].color = foreground; |
1575 | } | 1584 | } |
1576 | else if(i==1 || i == 11) | 1585 | else if(i==1 || i == 11) |
1577 | { | 1586 | { |
1578 | m_table[i].color = background; | 1587 | m_table[i].color = background; |
1579 | m_table[i].transparent=0; | 1588 | m_table[i].transparent=0; |
1580 | } | 1589 | } |
1581 | else | 1590 | else |
1582 | m_table[i].color = defaultCt[i].color; | 1591 | m_table[i].color = defaultCt[i].color; |
1583 | } | 1592 | } |
1584 | te->setColorTable(m_table); | 1593 | te->setColorTable(m_table); |
1585 | } | 1594 | } |
1586 | 1595 | ||
1587 | void Konsole::tabMenuSelected(int id) | 1596 | void Konsole::tabMenuSelected(int id) |
1588 | { | 1597 | { |
1589 | Config cfg( "Konsole" ); | 1598 | Config cfg( "Konsole" ); |
1590 | cfg.setGroup("Tabs"); | 1599 | cfg.setGroup("Tabs"); |
1591 | tabMenu->setItemChecked(tabPos, false); | 1600 | tabMenu->setItemChecked(tabPos, false); |
1592 | if (id == tm_bottom) | 1601 | if (id == tm_bottom) |
1593 | { | 1602 | { |
1594 | printf("set bottom tab\n"); | 1603 | printf("set bottom tab\n"); |
1595 | tab->getTabBar()->show(); | 1604 | tab->getTabBar()->show(); |
1596 | tab->setTabPosition(QTabWidget::Bottom); | 1605 | tab->setTabPosition(QTabWidget::Bottom); |
1597 | tab->getTabBar()->show(); | 1606 | tab->getTabBar()->show(); |
1598 | cfg.writeEntry("Position","Bottom"); | 1607 | cfg.writeEntry("Position","Bottom"); |
1599 | } | 1608 | } |
1600 | else if (id == tm_top) | 1609 | else if (id == tm_top) |
1601 | { | 1610 | { |
1602 | printf("set top tab\n"); | 1611 | printf("set top tab\n"); |
1603 | tab->getTabBar()->show(); | 1612 | tab->getTabBar()->show(); |
1604 | tab->setTabPosition(QTabWidget::Bottom); | 1613 | tab->setTabPosition(QTabWidget::Bottom); |
1605 | tab->setTabPosition(QTabWidget::Top); | 1614 | tab->setTabPosition(QTabWidget::Top); |
1606 | tab->getTabBar()->show(); | 1615 | tab->getTabBar()->show(); |
1607 | cfg.writeEntry("Position","Top"); | 1616 | cfg.writeEntry("Position","Top"); |
1608 | } | 1617 | } |
1609 | else if (id == tm_hidden) | 1618 | else if (id == tm_hidden) |
1610 | { | 1619 | { |
1611 | tab->getTabBar()->hide(); | 1620 | tab->getTabBar()->hide(); |
1612 | tab->setMargin(tab->margin()); | 1621 | tab->setMargin(tab->margin()); |
1613 | cfg.writeEntry("Position","Hidden"); | 1622 | cfg.writeEntry("Position","Hidden"); |
1614 | } | 1623 | } |
1615 | tabMenu->setItemChecked(id, true); | 1624 | tabMenu->setItemChecked(id, true); |
1616 | tabPos = id; | 1625 | tabPos = id; |
1617 | } | 1626 | } |
1618 | 1627 | ||
1619 | 1628 | ||
1620 | void Konsole::configMenuSelected(int iD) | 1629 | void Konsole::configMenuSelected(int iD) |
1621 | { | 1630 | { |
1622 | // QString temp; | 1631 | // QString temp; |
1623 | // odebug << temp.sprintf("configmenu " << iD) << "" << oendl; | 1632 | // odebug << temp.sprintf("configmenu " << iD) << "" << oendl; |
1624 | 1633 | ||
1625 | TEWidget* te = getTe(); | 1634 | TEWidget* te = getTe(); |
1626 | Config cfg( "Konsole" ); | 1635 | Config cfg( "Konsole" ); |
1627 | cfg.setGroup("Menubar"); | 1636 | cfg.setGroup("Menubar"); |
1628 | if(iD == cm_wrap) | 1637 | if(iD == cm_wrap) |
1629 | { | 1638 | { |
1630 | cfg.setGroup("ScrollBar"); | 1639 | cfg.setGroup("ScrollBar"); |
1631 | bool b=cfg.readBoolEntry("HorzScroll",0); | 1640 | bool b=cfg.readBoolEntry("HorzScroll",0); |
1632 | b=!b; | 1641 | b=!b; |
1633 | cfg.writeEntry("HorzScroll", b ); | 1642 | cfg.writeEntry("HorzScroll", b ); |
1634 | cfg.write(); | 1643 | cfg.write(); |
1635 | doWrap(); | 1644 | doWrap(); |
1636 | if(cfg.readNumEntry("Position",2) == 0) | 1645 | if(cfg.readNumEntry("Position",2) == 0) |
1637 | { | 1646 | { |
1638 | te->setScrollbarLocation(1); | 1647 | te->setScrollbarLocation(1); |
1639 | } | 1648 | } |
1640 | else | 1649 | else |
1641 | { | 1650 | { |
1642 | te->setScrollbarLocation(0); | 1651 | te->setScrollbarLocation(0); |
1643 | } | 1652 | } |
1644 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1653 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1645 | } | 1654 | } |
1646 | if(iD == cm_beep) | 1655 | if(iD == cm_beep) |
1647 | { | 1656 | { |
1648 | cfg.setGroup("Menubar"); | 1657 | cfg.setGroup("Menubar"); |
1649 | bool b=cfg.readBoolEntry("useBeep",0); | 1658 | bool b=cfg.readBoolEntry("useBeep",0); |
1650 | b=!b; | 1659 | b=!b; |
1651 | cfg.writeEntry("useBeep", b ); | 1660 | cfg.writeEntry("useBeep", b ); |
1652 | cfg.write(); | 1661 | cfg.write(); |
1653 | configMenu->setItemChecked(cm_beep,b); | 1662 | configMenu->setItemChecked(cm_beep,b); |
1654 | te->useBeep=b; | 1663 | te->useBeep=b; |
1655 | } | 1664 | } |
1656 | } | 1665 | } |
1657 | 1666 | ||
1658 | void Konsole::changeCommand(const QString &text, int c) | 1667 | void Konsole::changeCommand(const QString &text, int c) |
1659 | { | 1668 | { |
1660 | Config cfg( "Konsole" ); | 1669 | Config cfg( "Konsole" ); |
1661 | cfg.setGroup("Commands"); | 1670 | cfg.setGroup("Commands"); |
1662 | if(commonCmds[c] != text) | 1671 | if(commonCmds[c] != text) |
1663 | { | 1672 | { |
1664 | cfg.writeEntry(QString::number(c),text); | 1673 | cfg.writeEntry(QString::number(c),text); |
1665 | commonCombo->clearEdit(); | 1674 | commonCombo->clearEdit(); |
1666 | commonCombo->setCurrentItem(c); | 1675 | commonCombo->setCurrentItem(c); |
1667 | } | 1676 | } |
1668 | } | 1677 | } |
1669 | 1678 | ||
1670 | void Konsole::setColor(int sess) | 1679 | void Konsole::setColor(int sess) |
1671 | { | 1680 | { |
1672 | Config cfg( "Konsole" ); | 1681 | Config cfg( "Konsole" ); |
1673 | cfg.setGroup("Colors"); | 1682 | cfg.setGroup("Colors"); |
1674 | QColor foreground, background; | 1683 | QColor foreground, background; |
1675 | QString ss = QString("Session") + QString::number(sess); | 1684 | QString ss = QString("Session") + QString::number(sess); |
1676 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, | 1685 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, |
1677 | cfg.readNumEntry("foregroundRed",0xff)), | 1686 | cfg.readNumEntry("foregroundRed",0xff)), |
1678 | cfg.readNumEntry("foregroundGreen"+ss, | 1687 | cfg.readNumEntry("foregroundGreen"+ss, |
1679 | cfg.readNumEntry("foregroundGreen",0xff)), | 1688 | cfg.readNumEntry("foregroundGreen",0xff)), |
1680 | cfg.readNumEntry("foregroundBlue"+ss, | 1689 | cfg.readNumEntry("foregroundBlue"+ss, |
1681 | cfg.readNumEntry("foregroundBlue",0xff))); | 1690 | cfg.readNumEntry("foregroundBlue",0xff))); |
1682 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, | 1691 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, |
1683 | cfg.readNumEntry("backgroundRed",0)), | 1692 | cfg.readNumEntry("backgroundRed",0)), |
1684 | cfg.readNumEntry("backgroundGreen"+ss, | 1693 | cfg.readNumEntry("backgroundGreen"+ss, |
1685 | cfg.readNumEntry("backgroundGreen",0)), | 1694 | cfg.readNumEntry("backgroundGreen",0)), |
1686 | cfg.readNumEntry("backgroundBlue"+ss, | 1695 | cfg.readNumEntry("backgroundBlue"+ss, |
1687 | cfg.readNumEntry("backgroundBlue",0))); | 1696 | cfg.readNumEntry("backgroundBlue",0))); |
1688 | setColors(foreground, background); | 1697 | setColors(foreground, background); |
1689 | } | 1698 | } |
1690 | 1699 | ||
1691 | void Konsole::scrollMenuSelected(int index) | 1700 | void Konsole::scrollMenuSelected(int index) |
1692 | { | 1701 | { |
1693 | // odebug << "scrollbar menu " << index << "" << oendl; | 1702 | // odebug << "scrollbar menu " << index << "" << oendl; |
1694 | 1703 | ||
1695 | TEWidget* te = getTe(); | 1704 | TEWidget* te = getTe(); |
1696 | Config cfg( "Konsole" ); | 1705 | Config cfg( "Konsole" ); |
1697 | cfg.setGroup("ScrollBar"); | 1706 | cfg.setGroup("ScrollBar"); |
1698 | 1707 | ||
1699 | if(index == sm_none) | 1708 | if(index == sm_none) |
1700 | { | 1709 | { |
1701 | te->setScrollbarLocation(0); | 1710 | te->setScrollbarLocation(0); |
1702 | cfg.writeEntry("Position",0); | 1711 | cfg.writeEntry("Position",0); |
1703 | } | 1712 | } |
1704 | else if(index == sm_left) | 1713 | else if(index == sm_left) |
1705 | { | 1714 | { |
1706 | te->setScrollbarLocation(1); | 1715 | te->setScrollbarLocation(1); |
1707 | cfg.writeEntry("Position",1); | 1716 | cfg.writeEntry("Position",1); |
1708 | } | 1717 | } |
1709 | else if(index == sm_right) | 1718 | else if(index == sm_right) |
1710 | { | 1719 | { |
1711 | te->setScrollbarLocation(2); | 1720 | te->setScrollbarLocation(2); |
1712 | cfg.writeEntry("Position",2); | 1721 | cfg.writeEntry("Position",2); |
1713 | } | 1722 | } |
1714 | scrollMenu->setItemChecked(sm_none, index == sm_none); | 1723 | scrollMenu->setItemChecked(sm_none, index == sm_none); |
1715 | scrollMenu->setItemChecked(sm_left, index == sm_left); | 1724 | scrollMenu->setItemChecked(sm_left, index == sm_left); |
1716 | scrollMenu->setItemChecked(sm_right, index == sm_right); | 1725 | scrollMenu->setItemChecked(sm_right, index == sm_right); |
1717 | } | 1726 | } |
1718 | 1727 | ||
1719 | // case -29: { | 1728 | // case -29: { |
1720 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1729 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1721 | // cfg.writeEntry("HorzScroll", !b ); | 1730 | // cfg.writeEntry("HorzScroll", !b ); |
1722 | // cfg.write(); | 1731 | // cfg.write(); |
1723 | // if(cfg.readNumEntry("Position",2) == 0) { | 1732 | // if(cfg.readNumEntry("Position",2) == 0) { |
1724 | // te->setScrollbarLocation(1); | 1733 | // te->setScrollbarLocation(1); |
1725 | // te->setWrapAt(0); | 1734 | // te->setWrapAt(0); |
1726 | // } else { | 1735 | // } else { |
1727 | // te->setScrollbarLocation(0); | 1736 | // te->setScrollbarLocation(0); |
1728 | // te->setWrapAt(120); | 1737 | // te->setWrapAt(120); |
1729 | // } | 1738 | // } |
1730 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1739 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1731 | // } | 1740 | // } |
1732 | // break; | 1741 | // break; |
1733 | 1742 | ||
1734 | void Konsole::editCommandListMenuSelected(int iD) | 1743 | void Konsole::editCommandListMenuSelected(int iD) |
1735 | { | 1744 | { |
1736 | // QString temp; | 1745 | // QString temp; |
1737 | // odebug << temp.sprintf("edit command list " << iD) << "" << oendl; | 1746 | // odebug << temp.sprintf("edit command list " << iD) << "" << oendl; |
1738 | 1747 | ||
1739 | // FIXME: more cleanup needed here | 1748 | // FIXME: more cleanup needed here |
1740 | 1749 | ||
1741 | 1750 | ||
1742 | TEWidget* te = getTe(); | 1751 | TEWidget* te = getTe(); |
1743 | Config cfg( "Konsole" ); | 1752 | Config cfg( "Konsole" ); |
1744 | cfg.setGroup("Menubar"); | 1753 | cfg.setGroup("Menubar"); |
1745 | if( iD == ec_cmdlist) | 1754 | if( iD == ec_cmdlist) |
1746 | { | 1755 | { |
1747 | if(!secondToolBar->isHidden()) | 1756 | if(!secondToolBar->isHidden()) |
1748 | { | 1757 | { |
1749 | secondToolBar->hide(); | 1758 | secondToolBar->hide(); |
1750 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1759 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1751 | cfg.writeEntry("Hidden","TRUE"); | 1760 | cfg.writeEntry("Hidden","TRUE"); |
1752 | configMenu->setItemEnabled(ec_edit ,FALSE); | 1761 | configMenu->setItemEnabled(ec_edit ,FALSE); |
1753 | configMenu->setItemEnabled(ec_quick ,FALSE); | 1762 | configMenu->setItemEnabled(ec_quick ,FALSE); |
1754 | } | 1763 | } |
1755 | else | 1764 | else |
1756 | { | 1765 | { |
1757 | secondToolBar->show(); | 1766 | secondToolBar->show(); |
1758 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1767 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1759 | cfg.writeEntry("Hidden","FALSE"); | 1768 | cfg.writeEntry("Hidden","FALSE"); |
1760 | configMenu->setItemEnabled(ec_edit ,TRUE); | 1769 | configMenu->setItemEnabled(ec_edit ,TRUE); |
1761 | configMenu->setItemEnabled(ec_quick ,TRUE); | 1770 | configMenu->setItemEnabled(ec_quick ,TRUE); |
1762 | 1771 | ||
1763 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") | 1772 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") |
1764 | { | 1773 | { |
1765 | configMenu->setItemChecked(ec_edit,TRUE); | 1774 | configMenu->setItemChecked(ec_edit,TRUE); |
1766 | commonCombo->setEditable( TRUE ); | 1775 | commonCombo->setEditable( TRUE ); |
1767 | } | 1776 | } |
1768 | else | 1777 | else |
1769 | { | 1778 | { |
1770 | configMenu->setItemChecked(ec_edit,FALSE); | 1779 | configMenu->setItemChecked(ec_edit,FALSE); |
1771 | commonCombo->setEditable( FALSE ); | 1780 | commonCombo->setEditable( FALSE ); |
1772 | } | 1781 | } |
1773 | } | 1782 | } |
1774 | } | 1783 | } |
1775 | if( iD == ec_quick) | 1784 | if( iD == ec_quick) |
1776 | { | 1785 | { |
1777 | cfg.setGroup("Commands"); | 1786 | cfg.setGroup("Commands"); |
1778 | // odebug << "enableCommandEdit" << oendl; | 1787 | // odebug << "enableCommandEdit" << oendl; |
1779 | if( !configMenu->isItemChecked(iD) ) | 1788 | if( !configMenu->isItemChecked(iD) ) |
1780 | { | 1789 | { |
1781 | commonCombo->setEditable( TRUE ); | 1790 | commonCombo->setEditable( TRUE ); |
1782 | configMenu->setItemChecked(iD,TRUE); | 1791 | configMenu->setItemChecked(iD,TRUE); |
1783 | commonCombo->setCurrentItem(0); | 1792 | commonCombo->setCurrentItem(0); |
1784 | cfg.writeEntry("EditEnabled","TRUE"); | 1793 | cfg.writeEntry("EditEnabled","TRUE"); |
1785 | } | 1794 | } |
1786 | else | 1795 | else |
1787 | { | 1796 | { |
1788 | commonCombo->setEditable( FALSE ); | 1797 | commonCombo->setEditable( FALSE ); |
1789 | configMenu->setItemChecked(iD,FALSE); | 1798 | configMenu->setItemChecked(iD,FALSE); |
1790 | cfg.writeEntry("EditEnabled","FALSE"); | 1799 | cfg.writeEntry("EditEnabled","FALSE"); |
1791 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1800 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1792 | te->setFocus(); | 1801 | te->setFocus(); |
1793 | } | 1802 | } |
1794 | } | 1803 | } |
1795 | if(iD == ec_edit) | 1804 | if(iD == ec_edit) |
1796 | { | 1805 | { |
1797 | // "edit commands" | 1806 | // "edit commands" |
1798 | CommandEditDialog *m = new CommandEditDialog(this); | 1807 | CommandEditDialog *m = new CommandEditDialog(this); |
1799 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1808 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1800 | m->showMaximized(); | 1809 | m->showMaximized(); |
1801 | } | 1810 | } |
1802 | 1811 | ||
1803 | } | 1812 | } |
1804 | 1813 | ||
1805 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1814 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1806 | void Konsole::setDocument( const QString &cmd) | 1815 | void Konsole::setDocument( const QString &cmd) |
1807 | { | 1816 | { |
1808 | newSession(); | 1817 | newSession(); |
1809 | TEWidget* te = getTe(); | 1818 | TEWidget* te = getTe(); |
1810 | if(cmd.find("-e", 0, TRUE) != -1) | 1819 | if(cmd.find("-e", 0, TRUE) != -1) |
1811 | { | 1820 | { |
1812 | QString cmd2; | 1821 | QString cmd2; |
1813 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1822 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1814 | system(cmd2.latin1()); | 1823 | system(cmd2.latin1()); |
1815 | if(startUp <= 1 && nsessions < 2) | 1824 | if(startUp <= 1 && nsessions < 2) |
1816 | { | 1825 | { |
1817 | doneSession(getTe(), 0); | 1826 | doneSession(getTe(), 0); |
1818 | exit(0); | 1827 | exit(0); |
1819 | } | 1828 | } |
1820 | else | 1829 | else |
1821 | doneSession(getTe(), 0); | 1830 | doneSession(getTe(), 0); |
1822 | } | 1831 | } |
1823 | else | 1832 | else |
1824 | { | 1833 | { |
1825 | if (te != 0) | 1834 | if (te != 0) |
1826 | { | 1835 | { |
1827 | te->emitText(cmd+"\r"); | 1836 | te->emitText(cmd+"\r"); |
1828 | } | 1837 | } |
1829 | } | 1838 | } |
1830 | startUp++; | 1839 | startUp++; |
1831 | } | 1840 | } |
1832 | 1841 | ||
1833 | 1842 | ||
1834 | // what is the point of this when you can just | 1843 | // what is the point of this when you can just |
1835 | // run commands by using the shell directly?? | 1844 | // run commands by using the shell directly?? |
1836 | void Konsole::parseCommandLine() | 1845 | void Konsole::parseCommandLine() |
1837 | { | 1846 | { |
1838 | QString cmd; | 1847 | QString cmd; |
1839 | // newSession(); | 1848 | // newSession(); |
1840 | for (int i=1;i< qApp->argc();i++) | 1849 | for (int i=1;i< qApp->argc();i++) |
1841 | { | 1850 | { |
1842 | if( QString(qApp->argv()[i]) == "-e") | 1851 | if( QString(qApp->argv()[i]) == "-e") |
1843 | { | 1852 | { |
1844 | i++; | 1853 | i++; |
1845 | for ( int j=i;j< qApp->argc();j++) | 1854 | for ( int j=i;j< qApp->argc();j++) |
1846 | { | 1855 | { |
1847 | cmd+=QString(qApp->argv()[j])+" "; | 1856 | cmd+=QString(qApp->argv()[j])+" "; |
1848 | } | 1857 | } |
1849 | cmd.stripWhiteSpace(); | 1858 | cmd.stripWhiteSpace(); |
1850 | system(cmd.latin1()); | 1859 | system(cmd.latin1()); |
1851 | exit(0);//close(); | 1860 | exit(0);//close(); |
1852 | } // end -e switch | 1861 | } // end -e switch |
1853 | } | 1862 | } |
1854 | startUp++; | 1863 | startUp++; |
1855 | } | 1864 | } |
1856 | 1865 | ||
1857 | void Konsole::changeForegroundColor(const QColor &color) | 1866 | void Konsole::changeForegroundColor(const QColor &color) |
1858 | { | 1867 | { |
1859 | Config cfg( "Konsole" ); | 1868 | Config cfg( "Konsole" ); |
1860 | cfg.setGroup("Colors"); | 1869 | cfg.setGroup("Colors"); |
1861 | int r, g, b; | 1870 | int r, g, b; |
1862 | color.rgb(&r,&g,&b); | 1871 | color.rgb(&r,&g,&b); |
1863 | foreground.setRgb(r,g,b); | 1872 | foreground.setRgb(r,g,b); |
1864 | 1873 | ||
1865 | cfg.writeEntry("foreground",color.name()); | 1874 | cfg.writeEntry("foreground",color.name()); |
1866 | odebug << "foreground "+color.name() << oendl; | 1875 | odebug << "foreground "+color.name() << oendl; |
1867 | cfg.write(); | 1876 | cfg.write(); |
1868 | 1877 | ||
1869 | odebug << "do other dialog" << oendl; | 1878 | odebug << "do other dialog" << oendl; |
1870 | #ifdef QT_QWS_OPIE | 1879 | #ifdef QT_QWS_OPIE |
1871 | 1880 | ||
1872 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); | 1881 | Opie::OColorPopupMenu* penColorPopupMenu2 = new Opie::OColorPopupMenu(Qt::black, this,"background color"); |
1873 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1882 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1874 | SLOT(changeBackgroundColor(const QColor&))); | 1883 | SLOT(changeBackgroundColor(const QColor&))); |
1875 | penColorPopupMenu2->exec(); | 1884 | penColorPopupMenu2->exec(); |
1876 | #endif | 1885 | #endif |
1877 | } | 1886 | } |
1878 | 1887 | ||
1879 | void Konsole::changeBackgroundColor(const QColor &color) | 1888 | void Konsole::changeBackgroundColor(const QColor &color) |
1880 | { | 1889 | { |
1881 | 1890 | ||
1882 | odebug << "Change background" << oendl; | 1891 | odebug << "Change background" << oendl; |
1883 | Config cfg( "Konsole" ); | 1892 | Config cfg( "Konsole" ); |
1884 | cfg.setGroup("Colors"); | 1893 | cfg.setGroup("Colors"); |
1885 | int r, g, b; | 1894 | int r, g, b; |
1886 | color.rgb(&r,&g,&b); | 1895 | color.rgb(&r,&g,&b); |
1887 | background.setRgb(r,g,b); | 1896 | background.setRgb(r,g,b); |
1888 | cfg.writeEntry("background",color.name()); | 1897 | cfg.writeEntry("background",color.name()); |
1889 | odebug << "background "+color.name() << oendl; | 1898 | odebug << "background "+color.name() << oendl; |
1890 | cfg.write(); | 1899 | cfg.write(); |
1891 | } | 1900 | } |
1892 | 1901 | ||
1893 | void Konsole::doWrap() | 1902 | void Konsole::doWrap() |
1894 | { | 1903 | { |
1895 | Config cfg( "Konsole" ); | 1904 | Config cfg( "Konsole" ); |
1896 | cfg.setGroup("ScrollBar"); | 1905 | cfg.setGroup("ScrollBar"); |
1897 | TEWidget* te = getTe(); | 1906 | TEWidget* te = getTe(); |
1898 | if( !cfg.readBoolEntry("HorzScroll",0)) | 1907 | if( !cfg.readBoolEntry("HorzScroll",0)) |
1899 | { | 1908 | { |
1900 | te->setWrapAt(0); | 1909 | te->setWrapAt(0); |
1901 | configMenu->setItemChecked( cm_wrap,TRUE); | 1910 | configMenu->setItemChecked( cm_wrap,TRUE); |
1902 | } | 1911 | } |
1903 | else | 1912 | else |
1904 | { | 1913 | { |
1905 | // te->setWrapAt(90); | 1914 | // te->setWrapAt(90); |
1906 | te->setWrapAt(120); | 1915 | te->setWrapAt(120); |
1907 | configMenu->setItemChecked( cm_wrap,FALSE); | 1916 | configMenu->setItemChecked( cm_wrap,FALSE); |
1908 | } | 1917 | } |
1909 | } | 1918 | } |