summaryrefslogtreecommitdiff
authorjosef <josef>2002-11-01 11:12:54 (UTC)
committer josef <josef>2002-11-01 11:12:54 (UTC)
commit4c5a56dbaddb3ac6b587c61a8ba6841987cf60fa (patch) (unidiff)
tree0172b37a635518ab48dcd0919d803371722a58c6
parentf99ad6016519a2f553c52812bac7859adb9aaa94 (diff)
downloadopie-4c5a56dbaddb3ac6b587c61a8ba6841987cf60fa.zip
opie-4c5a56dbaddb3ac6b587c61a8ba6841987cf60fa.tar.gz
opie-4c5a56dbaddb3ac6b587c61a8ba6841987cf60fa.tar.bz2
- allow toggling of line wrap via menu, as requested
If there was an icon, an entry in the menu bar could be made.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp7
-rw-r--r--noncore/apps/opie-console/emulation_handler.h2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp43
-rw-r--r--noncore/apps/opie-console/mainwindow.h3
4 files changed, 54 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index e0f63cd..7924568 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,201 +1,206 @@
1#include <qwidget.h> 1#include <qwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3 3
4#include "TEWidget.h" 4#include "TEWidget.h"
5#include "TEmuVt102.h" 5#include "TEmuVt102.h"
6 6
7#include "profile.h" 7#include "profile.h"
8#include "emulation_handler.h" 8#include "emulation_handler.h"
9#include "script.h" 9#include "script.h"
10 10
11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 11EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
12 : QObject(0, name ) 12 : QObject(0, name )
13{ 13{
14 m_teWid = new TEWidget( parent, "TerminalMain"); 14 m_teWid = new TEWidget( parent, "TerminalMain");
15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar) 15 // use setWrapAt(0) for classic behaviour (wrap at screen width, no scrollbar)
16 // use setWrapAt(80) for normal console with scrollbar 16 // use setWrapAt(80) for normal console with scrollbar
17 m_teWid->setWrapAt(prof.readNumEntry("Wrap", 0) ? 0 : 80); 17 setWrap(prof.readNumEntry("Wrap", 0) ? 0 : 80);
18 m_teWid->setMinimumSize(150, 70 ); 18 m_teWid->setMinimumSize(150, 70 );
19 m_script = 0; 19 m_script = 0;
20 parent->resize( m_teWid->calcSize(80, 24 ) ); 20 parent->resize( m_teWid->calcSize(80, 24 ) );
21 m_teEmu = new TEmuVt102(m_teWid ); 21 m_teEmu = new TEmuVt102(m_teWid );
22 22
23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 23 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
24 this, SIGNAL(changeSize(int, int) ) ); 24 this, SIGNAL(changeSize(int, int) ) );
25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 25 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
26 this, SLOT(recvEmulation(const char*, int) ) ); 26 this, SLOT(recvEmulation(const char*, int) ) );
27 m_teEmu->setConnect( true ); 27 m_teEmu->setConnect( true );
28 m_teEmu->setHistory( TRUE ); 28 m_teEmu->setHistory( TRUE );
29 load( prof ); 29 load( prof );
30 30
31 31
32 32
33} 33}
34EmulationHandler::~EmulationHandler() { 34EmulationHandler::~EmulationHandler() {
35 if (isRecording()) 35 if (isRecording())
36 clearScript(); 36 clearScript();
37 delete m_teEmu; 37 delete m_teEmu;
38 delete m_teWid; 38 delete m_teWid;
39} 39}
40 40
41void EmulationHandler::load( const Profile& prof) { 41void EmulationHandler::load( const Profile& prof) {
42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 42 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
43 int num = prof.readNumEntry("Color"); 43 int num = prof.readNumEntry("Color");
44 setColor( foreColor(num), backColor(num) ); 44 setColor( foreColor(num), backColor(num) );
45 m_teWid->setBackgroundColor(backColor(num) ); 45 m_teWid->setBackgroundColor(backColor(num) );
46 46
47 int term = prof.readNumEntry("Terminal", 0) ; 47 int term = prof.readNumEntry("Terminal", 0) ;
48 switch(term) { 48 switch(term) {
49 default: 49 default:
50 case Profile::VT102: 50 case Profile::VT102:
51 case Profile::VT100: 51 case Profile::VT100:
52 m_teEmu->setKeytrans("vt100.keytab"); 52 m_teEmu->setKeytrans("vt100.keytab");
53 break; 53 break;
54 case Profile::Linux: 54 case Profile::Linux:
55 m_teEmu->setKeytrans("linux.keytab"); 55 m_teEmu->setKeytrans("linux.keytab");
56 break; 56 break;
57 case Profile::XTerm: 57 case Profile::XTerm:
58 m_teEmu->setKeytrans("default.Keytab"); 58 m_teEmu->setKeytrans("default.Keytab");
59 break; 59 break;
60 } 60 }
61} 61}
62void EmulationHandler::recv( const QByteArray& ar) { 62void EmulationHandler::recv( const QByteArray& ar) {
63 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 63 m_teEmu->onRcvBlock(ar.data(), ar.count() );
64} 64}
65void EmulationHandler::recvEmulation(const char* src, int len ) { 65void EmulationHandler::recvEmulation(const char* src, int len ) {
66 QByteArray ar(len); 66 QByteArray ar(len);
67 67
68 memcpy(ar.data(), src, sizeof(char) * len ); 68 memcpy(ar.data(), src, sizeof(char) * len );
69 if (isRecording()) 69 if (isRecording())
70 m_script->append(ar); 70 m_script->append(ar);
71 emit send(ar); 71 emit send(ar);
72} 72}
73QWidget* EmulationHandler::widget() { 73QWidget* EmulationHandler::widget() {
74 return m_teWid; 74 return m_teWid;
75} 75}
76/* 76/*
77 * allocate a new table of colors 77 * allocate a new table of colors
78 */ 78 */
79void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 79void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
80 ColorEntry table[TABLE_COLORS]; 80 ColorEntry table[TABLE_COLORS];
81 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 81 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
82 82
83 for (int i = 0; i < TABLE_COLORS; i++ ) { 83 for (int i = 0; i < TABLE_COLORS; i++ ) {
84 if ( i == 0 || i == 10 ) { 84 if ( i == 0 || i == 10 ) {
85 table[i].color = fore; 85 table[i].color = fore;
86 }else if ( i == 1 || i == 11 ) { 86 }else if ( i == 1 || i == 11 ) {
87 table[i].color = back; 87 table[i].color = back;
88 table[i].transparent = 0; 88 table[i].transparent = 0;
89 }else { 89 }else {
90 table[i].color = defaultCt[i].color; 90 table[i].color = defaultCt[i].color;
91 } 91 }
92 } 92 }
93 m_teWid->setColorTable(table ); 93 m_teWid->setColorTable(table );
94 m_teWid->update(); 94 m_teWid->update();
95} 95}
96QFont EmulationHandler::font( int id ) { 96QFont EmulationHandler::font( int id ) {
97 QString name; 97 QString name;
98 int size = 0; 98 int size = 0;
99 switch(id ) { 99 switch(id ) {
100 default: // fall through 100 default: // fall through
101 case 0: 101 case 0:
102 name = QString::fromLatin1("Micro"); 102 name = QString::fromLatin1("Micro");
103 size = 4; 103 size = 4;
104 break; 104 break;
105 case 1: 105 case 1:
106 name = QString::fromLatin1("Fixed"); 106 name = QString::fromLatin1("Fixed");
107 size = 7; 107 size = 7;
108 break; 108 break;
109 case 2: 109 case 2:
110 name = QString::fromLatin1("Fixed"); 110 name = QString::fromLatin1("Fixed");
111 size = 12; 111 size = 12;
112 break; 112 break;
113 } 113 }
114 QFont font(name, size, QFont::Normal ); 114 QFont font(name, size, QFont::Normal );
115 font.setFixedPitch(TRUE ); 115 font.setFixedPitch(TRUE );
116 return font; 116 return font;
117} 117}
118QColor EmulationHandler::foreColor(int col) { 118QColor EmulationHandler::foreColor(int col) {
119 QColor co; 119 QColor co;
120 /* we need to switch it */ 120 /* we need to switch it */
121 switch( col ) { 121 switch( col ) {
122 default: 122 default:
123 case Profile::White: 123 case Profile::White:
124 /* color is black */ 124 /* color is black */
125 co = Qt::white; 125 co = Qt::white;
126 break; 126 break;
127 case Profile::Black: 127 case Profile::Black:
128 co = Qt::black; 128 co = Qt::black;
129 break; 129 break;
130 case Profile::Green: 130 case Profile::Green:
131 qWarning("Foreground green"); 131 qWarning("Foreground green");
132 co = Qt::green; 132 co = Qt::green;
133 break; 133 break;
134 case Profile::Orange: 134 case Profile::Orange:
135 qWarning("Foreground orange"); 135 qWarning("Foreground orange");
136 co.setRgb( 231, 184, 98 ); 136 co.setRgb( 231, 184, 98 );
137 break; 137 break;
138 } 138 }
139 139
140 return co; 140 return co;
141} 141}
142QColor EmulationHandler::backColor(int col ) { 142QColor EmulationHandler::backColor(int col ) {
143 QColor co; 143 QColor co;
144 /* we need to switch it */ 144 /* we need to switch it */
145 switch( col ) { 145 switch( col ) {
146 default: 146 default:
147 case Profile::White: 147 case Profile::White:
148 /* color is white */ 148 /* color is white */
149 co = Qt::black; 149 co = Qt::black;
150 break; 150 break;
151 case Profile::Black: 151 case Profile::Black:
152 co = Qt::white; 152 co = Qt::white;
153 break; 153 break;
154 case Profile::Green: 154 case Profile::Green:
155 qWarning("Background black"); 155 qWarning("Background black");
156 co = Qt::black; 156 co = Qt::black;
157 break; 157 break;
158 case Profile::Orange: 158 case Profile::Orange:
159 qWarning("Background black"); 159 qWarning("Background black");
160 co = Qt::black; 160 co = Qt::black;
161 break; 161 break;
162 } 162 }
163 163
164 return co; 164 return co;
165} 165}
166 166
167QPushButton* EmulationHandler::cornerButton() { 167QPushButton* EmulationHandler::cornerButton() {
168 return m_teWid->cornerButton(); 168 return m_teWid->cornerButton();
169} 169}
170 170
171 171
172Script *EmulationHandler::script() { 172Script *EmulationHandler::script() {
173 return m_script; 173 return m_script;
174} 174}
175 175
176bool EmulationHandler::isRecording() { 176bool EmulationHandler::isRecording() {
177 return (m_script != 0); 177 return (m_script != 0);
178} 178}
179 179
180void EmulationHandler::startRecording() { 180void EmulationHandler::startRecording() {
181 if (!isRecording()) 181 if (!isRecording())
182 m_script = new Script(); 182 m_script = new Script();
183} 183}
184 184
185void EmulationHandler::clearScript() { 185void EmulationHandler::clearScript() {
186 if (isRecording()) { 186 if (isRecording()) {
187 delete m_script; 187 delete m_script;
188 m_script = 0; 188 m_script = 0;
189 } 189 }
190} 190}
191 191
192void EmulationHandler::runScript(const Script *script) { 192void EmulationHandler::runScript(const Script *script) {
193 emit send(script->script()); 193 emit send(script->script());
194} 194}
195 195
196void EmulationHandler::copy() { 196void EmulationHandler::copy() {
197 m_teWid->emitSelection(); 197 m_teWid->emitSelection();
198} 198}
199void EmulationHandler::paste() { 199void EmulationHandler::paste() {
200 m_teWid->pasteClipboard(); 200 m_teWid->pasteClipboard();
201} 201}
202
203void EmulationHandler::setWrap(int columns) {
204 m_teWid->setWrapAt(columns);
205}
206
diff --git a/noncore/apps/opie-console/emulation_handler.h b/noncore/apps/opie-console/emulation_handler.h
index 12abbc5..7bc6f16 100644
--- a/noncore/apps/opie-console/emulation_handler.h
+++ b/noncore/apps/opie-console/emulation_handler.h
@@ -1,92 +1,94 @@
1#ifndef OPIE_EMULATION_HANDLER_H 1#ifndef OPIE_EMULATION_HANDLER_H
2#define OPIE_EMULATION_HANDLER_H 2#define OPIE_EMULATION_HANDLER_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include <qcolor.h> 5#include <qcolor.h>
6#include <qcstring.h> 6#include <qcstring.h>
7 7
8/* 8/*
9 * Badly ibotty lacks the time to finish 9 * Badly ibotty lacks the time to finish
10 * his widget in time.. 10 * his widget in time..
11 * Never the less we've to have an EmulationWidget 11 * Never the less we've to have an EmulationWidget
12 * This is why I'm taking the inferior not cleaned 12 * This is why I'm taking the inferior not cleaned
13 * up TE* KDE STUFF 13 * up TE* KDE STUFF
14 */ 14 */
15 15
16/** 16/**
17 * This is the layer above the IOLayer* 17 * This is the layer above the IOLayer*
18 * This nice QObject here will get stuff from 18 * This nice QObject here will get stuff from
19 * got a slot and a signal 19 * got a slot and a signal
20 * the signal for data 20 * the signal for data
21 * the slot for receiving 21 * the slot for receiving
22 * it'll set up the widget internally 22 * it'll set up the widget internally
23 * and manage the communication between 23 * and manage the communication between
24 * the pre QByteArray world! 24 * the pre QByteArray world!
25 */ 25 */
26class Profile; 26class Profile;
27class QWidget; 27class QWidget;
28class QPushButton; 28class QPushButton;
29class TEWidget; 29class TEWidget;
30class TEmulation; 30class TEmulation;
31class QFont; 31class QFont;
32class Script; 32class Script;
33class EmulationHandler : public QObject { 33class EmulationHandler : public QObject {
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 /** 36 /**
37 * simple c'tor the parent of the TEWdiget 37 * simple c'tor the parent of the TEWdiget
38 * and a name 38 * and a name
39 * and a Profile 39 * and a Profile
40 */ 40 */
41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l ); 41 EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );
42 42
43 /** 43 /**
44 * delete all components 44 * delete all components
45 */ 45 */
46 ~EmulationHandler(); 46 ~EmulationHandler();
47 47
48 void load( const Profile& ); 48 void load( const Profile& );
49 QWidget* widget(); 49 QWidget* widget();
50 void setColor( const QColor& fore, const QColor& back ); 50 void setColor( const QColor& fore, const QColor& back );
51 QPushButton* cornerButton(); 51 QPushButton* cornerButton();
52 52
53 /* Scripts */ 53 /* Scripts */
54 /* Create a new script and record all typed characters */ 54 /* Create a new script and record all typed characters */
55 void startRecording(); 55 void startRecording();
56 56
57 /* Return whether we are currently recording a script */ 57 /* Return whether we are currently recording a script */
58 bool isRecording(); 58 bool isRecording();
59 59
60 /* Return the current script (or NULL) */ 60 /* Return the current script (or NULL) */
61 Script *script(); 61 Script *script();
62 62
63 /* Stop recording and remove the current script from memory */ 63 /* Stop recording and remove the current script from memory */
64 void clearScript(); 64 void clearScript();
65 65
66 /* Run a script by forwarding its keys to the EmulationLayer */ 66 /* Run a script by forwarding its keys to the EmulationLayer */
67 void runScript(const Script *); 67 void runScript(const Script *);
68 68
69 /* Propagate change to widget */
70 void setWrap(int columns);
69signals: 71signals:
70 void send( const QByteArray& ); 72 void send( const QByteArray& );
71 void changeSize(int rows, int cols ); 73 void changeSize(int rows, int cols );
72 74
73 75
74public slots: 76public slots:
75 void recv( const QByteArray& ); 77 void recv( const QByteArray& );
76 void paste(); 78 void paste();
77 void copy(); 79 void copy();
78 80
79private slots: 81private slots:
80 void recvEmulation( const char*, int len ); 82 void recvEmulation( const char*, int len );
81private: 83private:
82 QFont font( int ); 84 QFont font( int );
83 QColor foreColor(int ); 85 QColor foreColor(int );
84 QColor backColor(int ); 86 QColor backColor(int );
85 87
86private: 88private:
87 TEWidget* m_teWid; 89 TEWidget* m_teWid;
88 TEmulation* m_teEmu; 90 TEmulation* m_teEmu;
89 Script * m_script; 91 Script * m_script;
90}; 92};
91 93
92#endif 94#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 936b1b2..d221715 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -128,295 +128,303 @@ static char * filesave_xpm[] = {
128" +...z]n$ ", 128" +...z]n$ ",
129" +... "}; 129" +... "};
130 130
131 131
132 132
133MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) { 133MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
134 KeyTrans::loadAll(); 134 KeyTrans::loadAll();
135 for (int i = 0; i < KeyTrans::count(); i++ ) { 135 for (int i = 0; i < KeyTrans::count(); i++ ) {
136 KeyTrans* s = KeyTrans::find(i ); 136 KeyTrans* s = KeyTrans::find(i );
137 assert( s ); 137 assert( s );
138 } 138 }
139 m_factory = new MetaFactory(); 139 m_factory = new MetaFactory();
140 Default def(m_factory); 140 Default def(m_factory);
141 m_sessions.setAutoDelete( TRUE ); 141 m_sessions.setAutoDelete( TRUE );
142 m_curSession = 0; 142 m_curSession = 0;
143 m_manager = new ProfileManager( m_factory ); 143 m_manager = new ProfileManager( m_factory );
144 m_manager->load(); 144 m_manager->load();
145 m_scriptsData.setAutoDelete(TRUE); 145 m_scriptsData.setAutoDelete(TRUE);
146 146
147 initUI(); 147 initUI();
148 populateProfiles(); 148 populateProfiles();
149 populateScripts(); 149 populateScripts();
150} 150}
151void MainWindow::initUI() { 151void MainWindow::initUI() {
152 setToolBarsMovable( FALSE ); 152 setToolBarsMovable( FALSE );
153 153
154 /* tool bar for the menu */ 154 /* tool bar for the menu */
155 m_tool = new QToolBar( this ); 155 m_tool = new QToolBar( this );
156 m_tool->setHorizontalStretchable( TRUE ); 156 m_tool->setHorizontalStretchable( TRUE );
157 157
158 m_bar = new QMenuBar( m_tool ); 158 m_bar = new QMenuBar( m_tool );
159 m_console = new QPopupMenu( this ); 159 m_console = new QPopupMenu( this );
160 m_scripts = new QPopupMenu( this ); 160 m_scripts = new QPopupMenu( this );
161 m_sessionsPop= new QPopupMenu( this ); 161 m_sessionsPop= new QPopupMenu( this );
162 m_scriptsPop = new QPopupMenu( this ); 162 m_scriptsPop = new QPopupMenu( this );
163 163
164 /* add a toolbar for icons */ 164 /* add a toolbar for icons */
165 m_icons = new QToolBar(this); 165 m_icons = new QToolBar(this);
166 166
167 /* 167 /*
168 * the settings action 168 * the settings action
169 */ 169 */
170 m_setProfiles = new QAction(tr("Configure Profiles"), 170 m_setProfiles = new QAction(tr("Configure Profiles"),
171 Resource::loadPixmap( "SettingsIcon" ), 171 Resource::loadPixmap( "SettingsIcon" ),
172 QString::null, 0, this, 0); 172 QString::null, 0, this, 0);
173 m_setProfiles->addTo( m_console ); 173 m_setProfiles->addTo( m_console );
174 connect( m_setProfiles, SIGNAL(activated() ), 174 connect( m_setProfiles, SIGNAL(activated() ),
175 this, SLOT(slotConfigure() ) ); 175 this, SLOT(slotConfigure() ) );
176 176
177 m_console->insertSeparator(); 177 m_console->insertSeparator();
178 /* 178 /*
179 * new Action for new sessions 179 * new Action for new sessions
180 */ 180 */
181 QAction* newCon = new QAction(tr("New Connection"), 181 QAction* newCon = new QAction(tr("New Connection"),
182 Resource::loadPixmap( "new" ), 182 Resource::loadPixmap( "new" ),
183 QString::null, 0, this, 0); 183 QString::null, 0, this, 0);
184 newCon->addTo( m_console ); 184 newCon->addTo( m_console );
185 connect( newCon, SIGNAL(activated() ), 185 connect( newCon, SIGNAL(activated() ),
186 this, SLOT(slotNew() ) ); 186 this, SLOT(slotNew() ) );
187 187
188 m_console->insertSeparator(); 188 m_console->insertSeparator();
189 189
190 QAction *saveCon = new QAction(tr("Save Connection"), 190 QAction *saveCon = new QAction(tr("Save Connection"),
191 QPixmap( ( const char** ) filesave_xpm ) , QString::null, 191 QPixmap( ( const char** ) filesave_xpm ) , QString::null,
192 0, this, 0 ); 192 0, this, 0 );
193 saveCon->addTo( m_console ); 193 saveCon->addTo( m_console );
194 connect( saveCon, SIGNAL(activated() ), 194 connect( saveCon, SIGNAL(activated() ),
195 this, SLOT(slotSaveSession() ) ); 195 this, SLOT(slotSaveSession() ) );
196 m_console->insertSeparator(); 196 m_console->insertSeparator();
197 197
198 /* 198 /*
199 * connect action 199 * connect action
200 */ 200 */
201 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"), 201 m_connect = new QAction( tr("Connect"), Resource::loadPixmap("console/connected"),
202 QString::null, 0, this, 0 ); 202 QString::null, 0, this, 0 );
203 m_connect->addTo( m_console ); 203 m_connect->addTo( m_console );
204 connect(m_connect, SIGNAL(activated() ), 204 connect(m_connect, SIGNAL(activated() ),
205 this, SLOT(slotConnect() ) ); 205 this, SLOT(slotConnect() ) );
206 206
207 /* 207 /*
208 * disconnect action 208 * disconnect action
209 */ 209 */
210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"), 210 m_disconnect = new QAction( tr("Disconnect"), Resource::loadPixmap("console/notconnected"),
211 QString::null, 0, this, 0 ); 211 QString::null, 0, this, 0 );
212 m_disconnect->addTo( m_console ); 212 m_disconnect->addTo( m_console );
213 connect(m_disconnect, SIGNAL(activated() ), 213 connect(m_disconnect, SIGNAL(activated() ),
214 this, SLOT(slotDisconnect() ) ); 214 this, SLOT(slotDisconnect() ) );
215 215
216 m_console->insertSeparator(); 216 m_console->insertSeparator();
217 217
218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null, 218 m_transfer = new QAction( tr("Transfer file..."), Resource::loadPixmap("pass") , QString::null,
219 0, this, 0 ); 219 0, this, 0 );
220 m_transfer->addTo( m_console ); 220 m_transfer->addTo( m_console );
221 connect(m_transfer, SIGNAL(activated() ), 221 connect(m_transfer, SIGNAL(activated() ),
222 this, SLOT(slotTransfer() ) ); 222 this, SLOT(slotTransfer() ) );
223 223
224 /*
225 * immediate change of line wrap policy
226 */
227 m_isWrapped = false;
228 m_wrap = new QAction( tr("Line wrap"), Resource::loadPixmap( "linewrap" ), QString::null, 0, this, 0 );
229 m_wrap->addTo( m_console );
230 connect( m_wrap, SIGNAL( activated() ), SLOT( slotWrap() ) );
224 231
225 /* 232 /*
226 * fullscreen 233 * fullscreen
227 */ 234 */
228 m_isFullscreen = false; 235 m_isFullscreen = false;
229 236
230 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) 237 m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" )
231 , QString::null, 0, this, 0); 238 , QString::null, 0, this, 0);
232 m_fullscreen->addTo( m_console ); 239 m_fullscreen->addTo( m_console );
233 connect( m_fullscreen, SIGNAL( activated() ), 240 connect( m_fullscreen, SIGNAL( activated() ),
234 this, SLOT( slotFullscreen() ) ); 241 this, SLOT( slotFullscreen() ) );
235 242
236 m_console->insertSeparator(); 243 m_console->insertSeparator();
237 /* 244 /*
238 * terminate action 245 * terminate action
239 */ 246 */
240 m_terminate = new QAction(); 247 m_terminate = new QAction();
241 m_terminate->setText( tr("Terminate") ); 248 m_terminate->setText( tr("Terminate") );
242 m_terminate->addTo( m_console ); 249 m_terminate->addTo( m_console );
243 connect(m_terminate, SIGNAL(activated() ), 250 connect(m_terminate, SIGNAL(activated() ),
244 this, SLOT(slotTerminate() ) ); 251 this, SLOT(slotTerminate() ) );
245 252
246 m_closewindow = new QAction(); 253 m_closewindow = new QAction();
247 m_closewindow->setText( tr("Close Window") ); 254 m_closewindow->setText( tr("Close Window") );
248 m_closewindow->addTo( m_console ); 255 m_closewindow->addTo( m_console );
249 connect( m_closewindow, SIGNAL(activated() ), 256 connect( m_closewindow, SIGNAL(activated() ),
250 this, SLOT(slotClose() ) ); 257 this, SLOT(slotClose() ) );
251 258
252 259
253 /* 260 /*
254 * script actions 261 * script actions
255 */ 262 */
256 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0); 263 m_runScript_id = m_scripts->insertItem(tr("Run Script"), m_scriptsPop, -1, 0);
257 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int))); 264 connect(m_scriptsPop, SIGNAL(activated(int)), this, SLOT(slotRunScript(int)));
258 265
259 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 266 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
260 m_recordScript->addTo(m_scripts); 267 m_recordScript->addTo(m_scripts);
261 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 268 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
262 269
263 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 270 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
264 m_saveScript->addTo(m_scripts); 271 m_saveScript->addTo(m_scripts);
265 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 272 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
266 273
267 274
268 /* 275 /*
269 * action that open/closes the keyboard 276 * action that open/closes the keyboard
270 */ 277 */
271 m_openKeys = new QAction (tr("Open Keyboard..."), 278 m_openKeys = new QAction (tr("Open Keyboard..."),
272 Resource::loadPixmap( "console/keys/keyboard_icon" ), 279 Resource::loadPixmap( "console/keys/keyboard_icon" ),
273 QString::null, 0, this, 0); 280 QString::null, 0, this, 0);
274 m_openKeys->setToggleAction(true); 281 m_openKeys->setToggleAction(true);
275 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool))); 282 connect (m_openKeys, SIGNAL(toggled(bool)), this, SLOT(slotOpenKeb(bool)));
276 283
277 /* insert the submenu */ 284 /* insert the submenu */
278 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 285 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
279 -1, 0); 286 -1, 0);
280 287
281 /* insert the connection menu */ 288 /* insert the connection menu */
282 m_bar->insertItem( tr("Connection"), m_console ); 289 m_bar->insertItem( tr("Connection"), m_console );
283 290
284 /* the scripts menu */ 291 /* the scripts menu */
285 m_bar->insertItem( tr("Scripts"), m_scripts ); 292 m_bar->insertItem( tr("Scripts"), m_scripts );
286 293
287 /* and the keyboard */ 294 /* and the keyboard */
288 m_keyBar = new QToolBar(this); 295 m_keyBar = new QToolBar(this);
289 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 296 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
290 m_keyBar->setHorizontalStretchable( TRUE ); 297 m_keyBar->setHorizontalStretchable( TRUE );
291 m_keyBar->hide(); 298 m_keyBar->hide();
292 299
293 m_kb = new FunctionKeyboard(m_keyBar); 300 m_kb = new FunctionKeyboard(m_keyBar);
294 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)), 301 connect(m_kb, SIGNAL(keyPressed(FKey, ushort, ushort, bool)),
295 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool))); 302 this, SLOT(slotKeyReceived(FKey, ushort, ushort, bool)));
296 303
297 304
298 QAction *a = new QAction(tr("Copy"), 305 QAction *a = new QAction(tr("Copy"),
299 Resource::loadPixmap("copy"), QString::null, 306 Resource::loadPixmap("copy"), QString::null,
300 0, this, 0 ); 307 0, this, 0 );
301 //a->addTo( m_icons ); 308 //a->addTo( m_icons );
302 connect( a, SIGNAL(activated() ), 309 connect( a, SIGNAL(activated() ),
303 this, SLOT(slotCopy() ) ); 310 this, SLOT(slotCopy() ) );
304 311
305 QAction *paste = new QAction(tr("Paste"), 312 QAction *paste = new QAction(tr("Paste"),
306 Resource::loadPixmap("paste"), QString::null, 313 Resource::loadPixmap("paste"), QString::null,
307 0, this, 0 ); 314 0, this, 0 );
308 connect( paste, SIGNAL(activated() ), 315 connect( paste, SIGNAL(activated() ),
309 this, SLOT(slotPaste() ) ); 316 this, SLOT(slotPaste() ) );
310 317
311 318
312 newCon->addTo( m_icons ); 319 newCon->addTo( m_icons );
313 m_setProfiles->addTo( m_icons ); 320 m_setProfiles->addTo( m_icons );
314 paste->addTo( m_icons ); 321 paste->addTo( m_icons );
315 m_openKeys->addTo(m_icons); 322 m_openKeys->addTo(m_icons);
316 m_fullscreen->addTo( m_icons ); 323 m_fullscreen->addTo( m_icons );
317 324
318 m_connect->setEnabled( false ); 325 m_connect->setEnabled( false );
319 m_disconnect->setEnabled( false ); 326 m_disconnect->setEnabled( false );
320 m_terminate->setEnabled( false ); 327 m_terminate->setEnabled( false );
321 m_transfer->setEnabled( false ); 328 m_transfer->setEnabled( false );
322 m_scripts->setItemEnabled(m_runScript_id, false); 329 m_scripts->setItemEnabled(m_runScript_id, false);
323 m_recordScript->setEnabled( false ); 330 m_recordScript->setEnabled( false );
324 m_saveScript->setEnabled( false ); 331 m_saveScript->setEnabled( false );
325 m_fullscreen->setEnabled( false ); 332 m_fullscreen->setEnabled( false );
326 m_closewindow->setEnabled( false ); 333 m_closewindow->setEnabled( false );
334 m_wrap->setEnabled( false );
327 335
328 /* 336 /*
329 * connect to the menu activation 337 * connect to the menu activation
330 */ 338 */
331 connect( m_sessionsPop, SIGNAL(activated( int ) ), 339 connect( m_sessionsPop, SIGNAL(activated( int ) ),
332 this, SLOT(slotProfile( int ) ) ); 340 this, SLOT(slotProfile( int ) ) );
333 341
334 m_consoleWindow = new TabWidget( this, "blah"); 342 m_consoleWindow = new TabWidget( this, "blah");
335 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 343 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
336 this, SLOT(slotSessionChanged(Session*) ) ); 344 this, SLOT(slotSessionChanged(Session*) ) );
337 setCentralWidget( m_consoleWindow ); 345 setCentralWidget( m_consoleWindow );
338 346
339} 347}
340 348
341ProfileManager* MainWindow::manager() { 349ProfileManager* MainWindow::manager() {
342 return m_manager; 350 return m_manager;
343} 351}
344TabWidget* MainWindow::tabWidget() { 352TabWidget* MainWindow::tabWidget() {
345 return m_consoleWindow; 353 return m_consoleWindow;
346} 354}
347void MainWindow::populateProfiles() { 355void MainWindow::populateProfiles() {
348 m_sessionsPop->clear(); 356 m_sessionsPop->clear();
349 Profile::ValueList list = manager()->all(); 357 Profile::ValueList list = manager()->all();
350 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 358 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
351 m_sessionsPop->insertItem( (*it).name() ); 359 m_sessionsPop->insertItem( (*it).name() );
352 } 360 }
353 361
354} 362}
355 363
356void MainWindow::populateScripts() { 364void MainWindow::populateScripts() {
357 m_scriptsPop->clear(); 365 m_scriptsPop->clear();
358 m_scriptsData.clear(); 366 m_scriptsData.clear();
359 DocLnkSet files(QPEApplication::documentDir(), "text/plain"); 367 DocLnkSet files(QPEApplication::documentDir(), "text/plain");
360 QListIterator<DocLnk> dit(files.children()); 368 QListIterator<DocLnk> dit(files.children());
361 for (; dit.current(); ++dit) { 369 for (; dit.current(); ++dit) {
362 if (*dit && (*dit)->name().length()>0) { 370 if (*dit && (*dit)->name().length()>0) {
363 QFileInfo info((*dit)->file()); 371 QFileInfo info((*dit)->file());
364 if (info.extension(false) == "script") { 372 if (info.extension(false) == "script") {
365 m_scriptsData.append(new DocLnk(**dit)); 373 m_scriptsData.append(new DocLnk(**dit));
366 m_scriptsPop->insertItem((*dit)->name()); 374 m_scriptsPop->insertItem((*dit)->name());
367 } 375 }
368 } 376 }
369 } 377 }
370 378
371} 379}
372 380
373MainWindow::~MainWindow() { 381MainWindow::~MainWindow() {
374 delete m_factory; 382 delete m_factory;
375 manager()->save(); 383 manager()->save();
376} 384}
377 385
378MetaFactory* MainWindow::factory() { 386MetaFactory* MainWindow::factory() {
379 return m_factory; 387 return m_factory;
380} 388}
381 389
382Session* MainWindow::currentSession() { 390Session* MainWindow::currentSession() {
383 return m_curSession; 391 return m_curSession;
384} 392}
385 393
386QList<Session> MainWindow::sessions() { 394QList<Session> MainWindow::sessions() {
387 return m_sessions; 395 return m_sessions;
388} 396}
389 397
390void MainWindow::slotNew() { 398void MainWindow::slotNew() {
391 ProfileEditorDialog dlg(factory() ); 399 ProfileEditorDialog dlg(factory() );
392 dlg.showMaximized(); 400 dlg.showMaximized();
393 dlg.setCaption( tr("New Connection") ); 401 dlg.setCaption( tr("New Connection") );
394 int ret = dlg.exec(); 402 int ret = dlg.exec();
395 403
396 if ( ret == QDialog::Accepted ) { 404 if ( ret == QDialog::Accepted ) {
397 create( dlg.profile() ); 405 create( dlg.profile() );
398 } 406 }
399} 407}
400 408
401void MainWindow::slotRecordScript() { 409void MainWindow::slotRecordScript() {
402 if (currentSession()) { 410 if (currentSession()) {
403 currentSession()->emulationHandler()->startRecording(); 411 currentSession()->emulationHandler()->startRecording();
404 m_saveScript->setEnabled(true); 412 m_saveScript->setEnabled(true);
405 m_recordScript->setEnabled(false); 413 m_recordScript->setEnabled(false);
406 } 414 }
407} 415}
408 416
409void MainWindow::slotSaveScript() { 417void MainWindow::slotSaveScript() {
410 if (currentSession() && currentSession()->emulationHandler()->isRecording()) { 418 if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
411 QMap<QString, QStringList> map; 419 QMap<QString, QStringList> map;
412 QStringList text; 420 QStringList text;
413 text << "text/plain"; 421 text << "text/plain";
414 map.insert(tr("Script"), text ); 422 map.insert(tr("Script"), text );
415 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map); 423 QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
416 if (!filename.isEmpty()) { 424 if (!filename.isEmpty()) {
417 QFileInfo info(filename); 425 QFileInfo info(filename);
418 if (info.extension(FALSE) != "script") 426 if (info.extension(FALSE) != "script")
419 filename += ".script"; 427 filename += ".script";
420 DocLnk nf; 428 DocLnk nf;
421 nf.setType("text/plain"); 429 nf.setType("text/plain");
422 nf.setFile(filename); 430 nf.setFile(filename);
@@ -432,296 +440,331 @@ void MainWindow::slotSaveScript() {
432} 440}
433 441
434void MainWindow::slotRunScript(int id) { 442void MainWindow::slotRunScript(int id) {
435 if (currentSession()) { 443 if (currentSession()) {
436 int index = m_scriptsPop->indexOf(id); 444 int index = m_scriptsPop->indexOf(id);
437 DocLnk *lnk = m_scriptsData.at(index); 445 DocLnk *lnk = m_scriptsData.at(index);
438 QString filePath = lnk->file(); 446 QString filePath = lnk->file();
439 Script script(filePath); 447 Script script(filePath);
440 currentSession()->emulationHandler()->runScript(&script); 448 currentSession()->emulationHandler()->runScript(&script);
441 } 449 }
442} 450}
443 451
444void MainWindow::slotConnect() { 452void MainWindow::slotConnect() {
445 if ( currentSession() ) { 453 if ( currentSession() ) {
446 bool ret = currentSession()->layer()->open(); 454 bool ret = currentSession()->layer()->open();
447 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 455 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
448 QObject::tr("Failed"), 456 QObject::tr("Failed"),
449 QObject::tr("Connecting failed for this session.")); 457 QObject::tr("Connecting failed for this session."));
450 else { 458 else {
451 m_connect->setEnabled( false ); 459 m_connect->setEnabled( false );
452 m_disconnect->setEnabled( true ); 460 m_disconnect->setEnabled( true );
453 461
454 // if it does not support file transfer, disable the menu entry 462 // if it does not support file transfer, disable the menu entry
455 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 463 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
456 m_transfer->setEnabled( false ); 464 m_transfer->setEnabled( false );
457 } else { 465 } else {
458 m_transfer->setEnabled( true ); 466 m_transfer->setEnabled( true );
459 } 467 }
460 468
461 m_recordScript->setEnabled( true ); 469 m_recordScript->setEnabled( true );
462 m_scripts->setItemEnabled(m_runScript_id, true); 470 m_scripts->setItemEnabled(m_runScript_id, true);
463 } 471 }
464 } 472 }
465} 473}
466 474
467void MainWindow::slotDisconnect() { 475void MainWindow::slotDisconnect() {
468 if ( currentSession() ) { 476 if ( currentSession() ) {
469 currentSession()->layer()->close(); 477 currentSession()->layer()->close();
470 m_connect->setEnabled( true ); 478 m_connect->setEnabled( true );
471 m_disconnect->setEnabled( false ); 479 m_disconnect->setEnabled( false );
472 m_transfer->setEnabled( false ); 480 m_transfer->setEnabled( false );
473 m_recordScript->setEnabled( false); 481 m_recordScript->setEnabled( false);
474 m_saveScript->setEnabled( false ); 482 m_saveScript->setEnabled( false );
475 m_scripts->setItemEnabled(m_runScript_id, false); 483 m_scripts->setItemEnabled(m_runScript_id, false);
476 } 484 }
477} 485}
478 486
479void MainWindow::slotTerminate() { 487void MainWindow::slotTerminate() {
480 if ( currentSession() ) 488 if ( currentSession() )
481 currentSession()->layer()->close(); 489 currentSession()->layer()->close();
482 490
483 slotClose(); 491 slotClose();
484 /* FIXME move to the next session */ 492 /* FIXME move to the next session */
485} 493}
486 494
487void MainWindow::slotConfigure() { 495void MainWindow::slotConfigure() {
488 ConfigDialog conf( manager()->all(), factory() ); 496 ConfigDialog conf( manager()->all(), factory() );
489 conf.showMaximized(); 497 conf.showMaximized();
490 498
491 int ret = conf.exec(); 499 int ret = conf.exec();
492 500
493 if ( QDialog::Accepted == ret ) { 501 if ( QDialog::Accepted == ret ) {
494 manager()->setProfiles( conf.list() ); 502 manager()->setProfiles( conf.list() );
495 manager()->save(); 503 manager()->save();
496 populateProfiles(); 504 populateProfiles();
497 } 505 }
498} 506}
499/* 507/*
500 * we will remove 508 * we will remove
501 * this window from the tabwidget 509 * this window from the tabwidget
502 * remove it from the list 510 * remove it from the list
503 * delete it 511 * delete it
504 * and set the currentSession() 512 * and set the currentSession()
505 */ 513 */
506void MainWindow::slotClose() { 514void MainWindow::slotClose() {
507 if (!currentSession() ) 515 if (!currentSession() )
508 return; 516 return;
509 517
510 Session* ses = currentSession(); 518 Session* ses = currentSession();
511 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 519 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
512 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ 520 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
513 m_curSession = NULL; 521 m_curSession = NULL;
514 tabWidget()->remove( /*currentSession()*/ses ); 522 tabWidget()->remove( /*currentSession()*/ses );
515 /*it's autodelete */ 523 /*it's autodelete */
516 m_sessions.remove( ses ); 524 m_sessions.remove( ses );
517 qWarning("after remove!!"); 525 qWarning("after remove!!");
518 526
519 if (!currentSession() ) { 527 if (!currentSession() ) {
520 m_connect->setEnabled( false ); 528 m_connect->setEnabled( false );
521 m_disconnect->setEnabled( false ); 529 m_disconnect->setEnabled( false );
522 m_terminate->setEnabled( false ); 530 m_terminate->setEnabled( false );
523 m_transfer->setEnabled( false ); 531 m_transfer->setEnabled( false );
524 m_recordScript->setEnabled( false ); 532 m_recordScript->setEnabled( false );
525 m_saveScript->setEnabled( false ); 533 m_saveScript->setEnabled( false );
526 m_scripts->setItemEnabled(m_runScript_id, false); 534 m_scripts->setItemEnabled(m_runScript_id, false);
527 m_fullscreen->setEnabled( false ); 535 m_fullscreen->setEnabled( false );
536 m_wrap->setEnabled( false );
528 m_closewindow->setEnabled( false ); 537 m_closewindow->setEnabled( false );
529 } 538 }
530 539
531 m_kb->loadDefaults(); 540 m_kb->loadDefaults();
532} 541}
533 542
534/* 543/*
535 * We will get the name 544 * We will get the name
536 * Then the profile 545 * Then the profile
537 * and then we will make a profile 546 * and then we will make a profile
538 */ 547 */
539void MainWindow::slotProfile( int id) { 548void MainWindow::slotProfile( int id) {
540 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 549 Profile prof = manager()->profile( m_sessionsPop->text( id) );
541 create( prof ); 550 create( prof );
542} 551}
543void MainWindow::create( const Profile& prof ) { 552void MainWindow::create( const Profile& prof ) {
544 if(m_curSession) 553 if(m_curSession)
545 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 554 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
546 555
547 Session *ses = manager()->fromProfile( prof, tabWidget() ); 556 Session *ses = manager()->fromProfile( prof, tabWidget() );
548 557
549 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 558 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
550 { 559 {
551 QMessageBox::warning(this, 560 QMessageBox::warning(this,
552 QObject::tr("Session failed"), 561 QObject::tr("Session failed"),
553 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 562 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
554 //if(ses) delete ses; 563 //if(ses) delete ses;
555 return; 564 return;
556 } 565 }
557 566
558 m_sessions.append( ses ); 567 m_sessions.append( ses );
559 tabWidget()->add( ses ); 568 tabWidget()->add( ses );
560 tabWidget()->repaint(); 569 tabWidget()->repaint();
561 m_curSession = ses; 570 m_curSession = ses;
562 571
563 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 572 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
564 m_connect->setEnabled( true ); 573 m_connect->setEnabled( true );
565 m_disconnect->setEnabled( false ); 574 m_disconnect->setEnabled( false );
566 m_terminate->setEnabled( true ); 575 m_terminate->setEnabled( true );
567 m_fullscreen->setEnabled( true ); 576 m_fullscreen->setEnabled( true );
577 m_wrap->setEnabled( true );
568 m_closewindow->setEnabled( true ); 578 m_closewindow->setEnabled( true );
569 m_transfer->setEnabled( false ); 579 m_transfer->setEnabled( false );
570 m_recordScript->setEnabled( false ); 580 m_recordScript->setEnabled( false );
571 m_saveScript->setEnabled( false ); 581 m_saveScript->setEnabled( false );
572 m_scripts->setItemEnabled(m_runScript_id, false); 582 m_scripts->setItemEnabled(m_runScript_id, false);
573 583
574 // is io_layer wants direct connection, then autoconnect 584 // is io_layer wants direct connection, then autoconnect
575 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) { 585 //if ( ( m_curSession->layer() )->supports()[0] == 1 ) {
576 if (prof.autoConnect()) { 586 if (prof.autoConnect()) {
577 slotConnect(); 587 slotConnect();
578 } 588 }
579 589
580 590
581 QWidget *w = currentSession()->widget(); 591 QWidget *w = currentSession()->widget();
582 if(w) w->setFocus(); 592 if(w) w->setFocus();
583 593
594 if(currentSession()->profile().readNumEntry("Wrap", 80)){
595 m_isWrapped = true;
596 } else {
597 m_isWrapped = false;
598 }
599
584 m_kb->load(currentSession()->profile()); 600 m_kb->load(currentSession()->profile());
585} 601}
586 602
587void MainWindow::slotTransfer() 603void MainWindow::slotTransfer()
588{ 604{
589 if ( currentSession() ) { 605 if ( currentSession() ) {
590 Session *mysession = currentSession(); 606 Session *mysession = currentSession();
591 TransferDialog dlg(/*mysession->widgetStack()*/this, this); 607 TransferDialog dlg(/*mysession->widgetStack()*/this, this);
592 mysession->setTransferDialog(&dlg); 608 mysession->setTransferDialog(&dlg);
593 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0)); 609 //dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
594 //dlg.showMaximized(); 610 //dlg.showMaximized();
595 currentSession()->widgetStack()->addWidget(&dlg, -1); 611 currentSession()->widgetStack()->addWidget(&dlg, -1);
596 dlg.show(); 612 dlg.show();
597 //dlg.exec(); 613 //dlg.exec();
598 while(dlg.isRunning()) qApp->processEvents(); 614 while(dlg.isRunning()) qApp->processEvents();
599 mysession->setTransferDialog(0l); 615 mysession->setTransferDialog(0l);
600 } 616 }
601} 617}
602 618
603 619
604void MainWindow::slotOpenKeb(bool state) { 620void MainWindow::slotOpenKeb(bool state) {
605 621
606 if (state) m_keyBar->show(); 622 if (state) m_keyBar->show();
607 else m_keyBar->hide(); 623 else m_keyBar->hide();
608 624
609} 625}
610 626
611 627
612void MainWindow::slotOpenButtons( bool state ) { 628void MainWindow::slotOpenButtons( bool state ) {
613 629
614 if ( state ) { 630 if ( state ) {
615 m_buttonBar->show(); 631 m_buttonBar->show();
616 } else { 632 } else {
617 m_buttonBar->hide(); 633 m_buttonBar->hide();
618 } 634 }
619} 635}
620 636
621 637
622 638
623void MainWindow::slotSessionChanged( Session* ses ) { 639void MainWindow::slotSessionChanged( Session* ses ) {
624 qWarning("changed!"); 640 qWarning("changed!");
625 641
626 if(m_curSession) 642 if(m_curSession)
627 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide(); 643 if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
628 if(ses) 644 if(ses)
629 if(ses->transferDialog()) ses->transferDialog()->show(); 645 if(ses->transferDialog()) ses->transferDialog()->show();
630 646
631 if ( ses ) { 647 if ( ses ) {
632 m_curSession = ses; 648 m_curSession = ses;
633 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 649 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
634 if ( m_curSession->layer()->isConnected() ) { 650 if ( m_curSession->layer()->isConnected() ) {
635 m_connect->setEnabled( false ); 651 m_connect->setEnabled( false );
636 m_disconnect->setEnabled( true ); 652 m_disconnect->setEnabled( true );
637 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording()); 653 m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
638 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording()); 654 m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
639 m_scripts->setItemEnabled(m_runScript_id, true); 655 m_scripts->setItemEnabled(m_runScript_id, true);
640 } else { 656 } else {
641 m_connect->setEnabled( true ); 657 m_connect->setEnabled( true );
642 m_disconnect->setEnabled( false ); 658 m_disconnect->setEnabled( false );
643 m_recordScript->setEnabled( false ); 659 m_recordScript->setEnabled( false );
644 m_saveScript->setEnabled( false ); 660 m_saveScript->setEnabled( false );
645 m_scripts->setItemEnabled(m_runScript_id, false); 661 m_scripts->setItemEnabled(m_runScript_id, false);
646 } 662 }
647 663
648 if ( ( m_curSession->layer() )->supports()[1] == 0 ) { 664 if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
649 m_transfer->setEnabled( false ); 665 m_transfer->setEnabled( false );
650 } else { 666 } else {
651 m_transfer->setEnabled( true ); 667 m_transfer->setEnabled( true );
652 } 668 }
653 669
654 QWidget *w = m_curSession->widget(); 670 QWidget *w = m_curSession->widget();
655 if(w) w->setFocus(); 671 if(w) w->setFocus();
656 672
673 if(currentSession()->profile().readNumEntry("Wrap", 80)){
674 m_isWrapped = true;
675 } else {
676 m_isWrapped = false;
677 }
678
657 m_kb->load(currentSession()->profile()); 679 m_kb->load(currentSession()->profile());
658 } 680 }
659} 681}
660 682
683void MainWindow::slotWrap()
684{
685 if(m_curSession)
686 {
687 EmulationHandler *e = m_curSession->emulationHandler();
688 if(e)
689 {
690 if(m_isWrapped)
691 {
692 e->setWrap(80);
693 m_isWrapped = false;
694 }
695 else
696 {
697 e->setWrap(0);
698 m_isWrapped = true;
699 }
700 }
701 }
702}
703
661void MainWindow::slotFullscreen() { 704void MainWindow::slotFullscreen() {
662 705
663 706
664 707
665 if ( m_isFullscreen ) { 708 if ( m_isFullscreen ) {
666 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true ); 709 ( m_curSession->widgetStack() )->reparent( savedParentFullscreen, 0, QPoint(0,0), true );
667 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() ); 710 ( m_curSession->widgetStack() )->resize( savedParentFullscreen->width(), savedParentFullscreen->height() );
668 ( m_curSession->emulationHandler() )->cornerButton()->hide(); 711 ( m_curSession->emulationHandler() )->cornerButton()->hide();
669 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 712 disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
670 713
671 } else { 714 } else {
672 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget(); 715 savedParentFullscreen = ( m_curSession->widgetStack() )->parentWidget();
673 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 716 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
674 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop 717 ( m_curSession->widgetStack() )->reparent( 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop
675 , QPoint(0,0), false ); 718 , QPoint(0,0), false );
676 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); 719 ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() );
677 ( m_curSession->widgetStack() )->setFocus(); 720 ( m_curSession->widgetStack() )->setFocus();
678 ( m_curSession->widgetStack() )->show(); 721 ( m_curSession->widgetStack() )->show();
679 722
680 ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); 723 ( ( m_curSession->emulationHandler() )->cornerButton() )->show();
681 724
682 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 725 connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
683 } 726 }
684 727
685 m_isFullscreen = !m_isFullscreen; 728 m_isFullscreen = !m_isFullscreen;
686} 729}
687 730
688 731
689void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) { 732void MainWindow::slotKeyReceived(FKey k, ushort, ushort, bool pressed) {
690 733
691 if ( m_curSession ) { 734 if ( m_curSession ) {
692 735
693 QEvent::Type state; 736 QEvent::Type state;
694 737
695 if (pressed) state = QEvent::KeyPress; 738 if (pressed) state = QEvent::KeyPress;
696 else state = QEvent::KeyRelease; 739 else state = QEvent::KeyRelease;
697 740
698 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode))); 741 QKeyEvent ke(state, k.qcode, k.unicode, 0, QString(QChar(k.unicode)));
699 742
700 // is this the best way to do this? cant figure out any other way to work 743 // is this the best way to do this? cant figure out any other way to work
701 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); 744 QApplication::sendEvent((QObject *)m_curSession->widget(), &ke);
702 ke.ignore(); 745 ke.ignore();
703 } 746 }
704} 747}
705void MainWindow::slotCopy() { 748void MainWindow::slotCopy() {
706 if (!currentSession() ) return; 749 if (!currentSession() ) return;
707 currentSession()->emulationHandler()->copy(); 750 currentSession()->emulationHandler()->copy();
708} 751}
709void MainWindow::slotPaste() { 752void MainWindow::slotPaste() {
710 if (!currentSession() ) return; 753 if (!currentSession() ) return;
711 currentSession()->emulationHandler()->paste(); 754 currentSession()->emulationHandler()->paste();
712} 755}
713 756
714/* 757/*
715 * Save the session 758 * Save the session
716 */ 759 */
717 760
718void MainWindow::slotSaveSession() { 761void MainWindow::slotSaveSession() {
719 if (!currentSession() ) { 762 if (!currentSession() ) {
720 QMessageBox::information(this, tr("Save Connection"), 763 QMessageBox::information(this, tr("Save Connection"),
721 tr("<qt>There is no Connection.</qt>"), 1 ); 764 tr("<qt>There is no Connection.</qt>"), 1 );
722 return; 765 return;
723 } 766 }
724 manager()->add( currentSession()->profile() ); 767 manager()->add( currentSession()->profile() );
725 manager()->save(); 768 manager()->save();
726 populateProfiles(); 769 populateProfiles();
727} 770}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 3b16f0a..37219c5 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,132 +1,135 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QToolButton; 15class QToolButton;
16class QMenuBar; 16class QMenuBar;
17class QAction; 17class QAction;
18class MetaFactory; 18class MetaFactory;
19class TabWidget; 19class TabWidget;
20class ProfileManager; 20class ProfileManager;
21class Profile; 21class Profile;
22class FunctionKeyboard; 22class FunctionKeyboard;
23class FKey; 23class FKey;
24class DocLnk; 24class DocLnk;
25 25
26class MainWindow : public QMainWindow { 26class MainWindow : public QMainWindow {
27 Q_OBJECT 27 Q_OBJECT
28public: 28public:
29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 29 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
30 ~MainWindow(); 30 ~MainWindow();
31 31
32 /** 32 /**
33 * our factory to generate IOLayer and so on 33 * our factory to generate IOLayer and so on
34 * 34 *
35 */ 35 */
36 MetaFactory* factory(); 36 MetaFactory* factory();
37 37
38 /** 38 /**
39 * A session contains a QWidget*, 39 * A session contains a QWidget*,
40 * an IOLayer* and some infos for us 40 * an IOLayer* and some infos for us
41 */ 41 */
42 Session* currentSession(); 42 Session* currentSession();
43 43
44 /** 44 /**
45 * the session list 45 * the session list
46 */ 46 */
47 QList<Session> sessions(); 47 QList<Session> sessions();
48 48
49 /** 49 /**
50 * 50 *
51 */ 51 */
52 ProfileManager* manager(); 52 ProfileManager* manager();
53 TabWidget* tabWidget(); 53 TabWidget* tabWidget();
54 54
55private slots: 55private slots:
56 void slotNew(); 56 void slotNew();
57 void slotConnect(); 57 void slotConnect();
58 void slotDisconnect(); 58 void slotDisconnect();
59 void slotTerminate(); 59 void slotTerminate();
60 void slotConfigure(); 60 void slotConfigure();
61 void slotClose(); 61 void slotClose();
62 void slotProfile(int); 62 void slotProfile(int);
63 void slotTransfer(); 63 void slotTransfer();
64 void slotOpenKeb(bool); 64 void slotOpenKeb(bool);
65 void slotOpenButtons(bool); 65 void slotOpenButtons(bool);
66 void slotRecordScript(); 66 void slotRecordScript();
67 void slotSaveScript(); 67 void slotSaveScript();
68 void slotRunScript(int); 68 void slotRunScript(int);
69 void slotFullscreen(); 69 void slotFullscreen();
70 void slotWrap();
70 void slotSessionChanged( Session* ); 71 void slotSessionChanged( Session* );
71 void slotKeyReceived(FKey, ushort, ushort, bool); 72 void slotKeyReceived(FKey, ushort, ushort, bool);
72 73
73 /* what could these both slot do? */ 74 /* what could these both slot do? */
74 void slotCopy(); 75 void slotCopy();
75 void slotPaste(); 76 void slotPaste();
76 77
77 /* save the currentSession() to Profiles */ 78 /* save the currentSession() to Profiles */
78 void slotSaveSession(); 79 void slotSaveSession();
79 80
80private: 81private:
81 void initUI(); 82 void initUI();
82 void populateProfiles(); 83 void populateProfiles();
83 void populateScripts(); 84 void populateScripts();
84 void create( const Profile& ); 85 void create( const Profile& );
85 /** 86 /**
86 * the current session 87 * the current session
87 */ 88 */
88 Session* m_curSession; 89 Session* m_curSession;
89 90
90 /** 91 /**
91 * the session list 92 * the session list
92 */ 93 */
93 QList<Session> m_sessions; 94 QList<Session> m_sessions;
94 QList<DocLnk> m_scriptsData; 95 QList<DocLnk> m_scriptsData;
95 96
96 /** 97 /**
97 * the metafactory 98 * the metafactory
98 */ 99 */
99 MetaFactory* m_factory; 100 MetaFactory* m_factory;
100 ProfileManager* m_manager; 101 ProfileManager* m_manager;
101 102
102 TabWidget* m_consoleWindow; 103 TabWidget* m_consoleWindow;
103 QToolBar* m_tool; 104 QToolBar* m_tool;
104 QToolBar* m_icons; 105 QToolBar* m_icons;
105 QToolBar* m_keyBar; 106 QToolBar* m_keyBar;
106 QToolBar* m_buttonBar; 107 QToolBar* m_buttonBar;
107 QMenuBar* m_bar; 108 QMenuBar* m_bar;
108 QPopupMenu* m_console; 109 QPopupMenu* m_console;
109 QPopupMenu* m_sessionsPop; 110 QPopupMenu* m_sessionsPop;
110 QPopupMenu* m_scriptsPop; 111 QPopupMenu* m_scriptsPop;
111 QPopupMenu* m_scripts; 112 QPopupMenu* m_scripts;
112 QAction* m_connect; 113 QAction* m_connect;
113 QAction* m_disconnect; 114 QAction* m_disconnect;
114 QAction* m_terminate; 115 QAction* m_terminate;
115 QAction* m_transfer; 116 QAction* m_transfer;
116 QAction* m_setProfiles; 117 QAction* m_setProfiles;
117 QAction* m_openKeys; 118 QAction* m_openKeys;
118 QAction* m_openButtons; 119 QAction* m_openButtons;
119 QAction* m_recordScript; 120 QAction* m_recordScript;
120 QAction* m_saveScript; 121 QAction* m_saveScript;
121 QAction* m_fullscreen; 122 QAction* m_fullscreen;
123 QAction* m_wrap;
122 QAction* m_closewindow; 124 QAction* m_closewindow;
123 125
124 FunctionKeyboard *m_kb; 126 FunctionKeyboard *m_kb;
125 int m_runScript_id; 127 int m_runScript_id;
126 bool m_isFullscreen; 128 bool m_isFullscreen;
129 bool m_isWrapped;
127 130
128 QWidget* savedParentFullscreen; 131 QWidget* savedParentFullscreen;
129}; 132};
130 133
131 134
132#endif 135#endif