summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-10-13 16:26:06 (UTC)
committer harlekin <harlekin>2002-10-13 16:26:06 (UTC)
commit40e7d87b58e6146944da4613c04bfafc90dbb379 (patch) (unidiff)
treeaafd035889122c111218fd510821d8dd47d5983c
parent93133ba6cc82398012c8f7206a7e9a270a04edc6 (diff)
downloadopie-40e7d87b58e6146944da4613c04bfafc90dbb379.zip
opie-40e7d87b58e6146944da4613c04bfafc90dbb379.tar.gz
opie-40e7d87b58e6146944da4613c04bfafc90dbb379.tar.bz2
fullscreen for new connection
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp21
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp2
2 files changed, 12 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 46c5bed..0a58b6c 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,329 +1,330 @@
1 1
2#include <qaction.h> 2#include <qaction.h>
3#include <qmenubar.h> 3#include <qmenubar.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qtoolbar.h> 6#include <qtoolbar.h>
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <opie/ofiledialog.h> 8#include <opie/ofiledialog.h>
9 9
10#include "profileeditordialog.h" 10#include "profileeditordialog.h"
11#include "configdialog.h" 11#include "configdialog.h"
12#include "default.h" 12#include "default.h"
13#include "metafactory.h" 13#include "metafactory.h"
14#include "profile.h" 14#include "profile.h"
15#include "profilemanager.h" 15#include "profilemanager.h"
16#include "mainwindow.h" 16#include "mainwindow.h"
17#include "tabwidget.h" 17#include "tabwidget.h"
18#include "transferdialog.h" 18#include "transferdialog.h"
19#include "function_keyboard.h" 19#include "function_keyboard.h"
20#include "script.h" 20#include "script.h"
21 21
22MainWindow::MainWindow() { 22MainWindow::MainWindow() {
23 m_factory = new MetaFactory(); 23 m_factory = new MetaFactory();
24 Default def(m_factory); 24 Default def(m_factory);
25 m_sessions.setAutoDelete( TRUE ); 25 m_sessions.setAutoDelete( TRUE );
26 m_curSession = 0; 26 m_curSession = 0;
27 m_manager = new ProfileManager( m_factory ); 27 m_manager = new ProfileManager( m_factory );
28 m_manager->load(); 28 m_manager->load();
29 29
30 initUI(); 30 initUI();
31 populateProfiles(); 31 populateProfiles();
32} 32}
33void MainWindow::initUI() { 33void MainWindow::initUI() {
34 setToolBarsMovable( FALSE ); 34 setToolBarsMovable( FALSE );
35 35
36 /* tool bar for the menu */ 36 /* tool bar for the menu */
37 m_tool = new QToolBar( this ); 37 m_tool = new QToolBar( this );
38 m_tool->setHorizontalStretchable( TRUE ); 38 m_tool->setHorizontalStretchable( TRUE );
39 39
40 m_bar = new QMenuBar( m_tool ); 40 m_bar = new QMenuBar( m_tool );
41 m_console = new QPopupMenu( this ); 41 m_console = new QPopupMenu( this );
42 m_scripts = new QPopupMenu( this ); 42 m_scripts = new QPopupMenu( this );
43 m_sessionsPop= new QPopupMenu( this ); 43 m_sessionsPop= new QPopupMenu( this );
44 m_settings = new QPopupMenu( this ); 44 m_settings = new QPopupMenu( this );
45 45
46 /* add a toolbar for icons */ 46 /* add a toolbar for icons */
47 m_icons = new QToolBar(this); 47 m_icons = new QToolBar(this);
48 48
49 /* 49 /*
50 * new Action for new sessions 50 * new Action for new sessions
51 */ 51 */
52 QAction* a = new QAction(tr("New Connection"), 52 QAction* a = new QAction(tr("New Connection"),
53 Resource::loadPixmap( "new" ), 53 Resource::loadPixmap( "new" ),
54 QString::null, 0, this, 0); 54 QString::null, 0, this, 0);
55 a->addTo( m_console ); 55 a->addTo( m_console );
56 a->addTo( m_icons ); 56 a->addTo( m_icons );
57 connect(a, SIGNAL(activated() ), 57 connect(a, SIGNAL(activated() ),
58 this, SLOT(slotNew() ) ); 58 this, SLOT(slotNew() ) );
59 59
60 /* 60 /*
61 * connect action 61 * connect action
62 */ 62 */
63 m_connect = new QAction(); 63 m_connect = new QAction();
64 m_connect->setText( tr("Connect") ); 64 m_connect->setText( tr("Connect") );
65 m_connect->addTo( m_console ); 65 m_connect->addTo( m_console );
66 connect(m_connect, SIGNAL(activated() ), 66 connect(m_connect, SIGNAL(activated() ),
67 this, SLOT(slotConnect() ) ); 67 this, SLOT(slotConnect() ) );
68 68
69 /* 69 /*
70 * disconnect action 70 * disconnect action
71 */ 71 */
72 m_disconnect = new QAction(); 72 m_disconnect = new QAction();
73 m_disconnect->setText( tr("Disconnect") ); 73 m_disconnect->setText( tr("Disconnect") );
74 m_disconnect->addTo( m_console ); 74 m_disconnect->addTo( m_console );
75 connect(m_disconnect, SIGNAL(activated() ), 75 connect(m_disconnect, SIGNAL(activated() ),
76 this, SLOT(slotDisconnect() ) ); 76 this, SLOT(slotDisconnect() ) );
77 77
78 m_transfer = new QAction(); 78 m_transfer = new QAction();
79 m_transfer->setText( tr("Transfer file...") ); 79 m_transfer->setText( tr("Transfer file...") );
80 m_transfer->addTo( m_console ); 80 m_transfer->addTo( m_console );
81 connect(m_transfer, SIGNAL(activated() ), 81 connect(m_transfer, SIGNAL(activated() ),
82 this, SLOT(slotTransfer() ) ); 82 this, SLOT(slotTransfer() ) );
83 83
84 /* 84 /*
85 * terminate action 85 * terminate action
86 */ 86 */
87 m_terminate = new QAction(); 87 m_terminate = new QAction();
88 m_terminate->setText( tr("Terminate") ); 88 m_terminate->setText( tr("Terminate") );
89 m_terminate->addTo( m_console ); 89 m_terminate->addTo( m_console );
90 connect(m_terminate, SIGNAL(activated() ), 90 connect(m_terminate, SIGNAL(activated() ),
91 this, SLOT(slotTerminate() ) ); 91 this, SLOT(slotTerminate() ) );
92 92
93 a = new QAction(); 93 a = new QAction();
94 a->setText( tr("Close Window") ); 94 a->setText( tr("Close Window") );
95 a->addTo( m_console ); 95 a->addTo( m_console );
96 connect(a, SIGNAL(activated() ), 96 connect(a, SIGNAL(activated() ),
97 this, SLOT(slotClose() ) ); 97 this, SLOT(slotClose() ) );
98 98
99 /* 99 /*
100 * the settings action 100 * the settings action
101 */ 101 */
102 m_setProfiles = new QAction(tr("Configure Profiles"), 102 m_setProfiles = new QAction(tr("Configure Profiles"),
103 Resource::loadPixmap( "SettingsIcon" ), 103 Resource::loadPixmap( "SettingsIcon" ),
104 QString::null, 0, this, 0); 104 QString::null, 0, this, 0);
105 m_setProfiles->addTo( m_settings ); 105 m_setProfiles->addTo( m_settings );
106 m_setProfiles->addTo( m_icons ); 106 m_setProfiles->addTo( m_icons );
107 connect( m_setProfiles, SIGNAL(activated() ), 107 connect( m_setProfiles, SIGNAL(activated() ),
108 this, SLOT(slotConfigure() ) ); 108 this, SLOT(slotConfigure() ) );
109 109
110 /* 110 /*
111 * script actions 111 * script actions
112 */ 112 */
113 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); 113 m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
114 m_recordScript->addTo(m_scripts); 114 m_recordScript->addTo(m_scripts);
115 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); 115 connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
116 116
117 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); 117 m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
118 m_saveScript->addTo(m_scripts); 118 m_saveScript->addTo(m_scripts);
119 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); 119 connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
120 120
121 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); 121 m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
122 m_runScript->addTo(m_scripts); 122 m_runScript->addTo(m_scripts);
123 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); 123 connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
124 124
125 /* 125 /*
126 * action that open/closes the keyboard 126 * action that open/closes the keyboard
127 */ 127 */
128 m_openKeys = new QAction (tr("Open Keyboard..."), 128 m_openKeys = new QAction (tr("Open Keyboard..."),
129 Resource::loadPixmap( "down" ), 129 Resource::loadPixmap( "down" ),
130 QString::null, 0, this, 0); 130 QString::null, 0, this, 0);
131 131
132 m_openKeys->setToggleAction(true); 132 m_openKeys->setToggleAction(true);
133 133
134 connect (m_openKeys, SIGNAL(toggled(bool)), 134 connect (m_openKeys, SIGNAL(toggled(bool)),
135 this, SLOT(slotOpenKeb(bool))); 135 this, SLOT(slotOpenKeb(bool)));
136 m_openKeys->addTo(m_icons); 136 m_openKeys->addTo(m_icons);
137 137
138 138
139 /* insert the submenu */ 139 /* insert the submenu */
140 m_console->insertItem(tr("New from Profile"), m_sessionsPop, 140 m_console->insertItem(tr("New from Profile"), m_sessionsPop,
141 -1, 0); 141 -1, 0);
142 142
143 /* insert the connection menu */ 143 /* insert the connection menu */
144 m_bar->insertItem( tr("Connection"), m_console ); 144 m_bar->insertItem( tr("Connection"), m_console );
145 145
146 /* the scripts menu */ 146 /* the scripts menu */
147 m_bar->insertItem( tr("Scripts"), m_scripts ); 147 m_bar->insertItem( tr("Scripts"), m_scripts );
148 148
149 /* the settings menu */ 149 /* the settings menu */
150 m_bar->insertItem( tr("Settings"), m_settings ); 150 m_bar->insertItem( tr("Settings"), m_settings );
151 151
152 /* and the keyboard */ 152 /* and the keyboard */
153 m_keyBar = new QToolBar(this); 153 m_keyBar = new QToolBar(this);
154 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); 154 addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE );
155 m_keyBar->setHorizontalStretchable( TRUE ); 155 m_keyBar->setHorizontalStretchable( TRUE );
156 m_keyBar->hide(); 156 m_keyBar->hide();
157 157
158 m_kb = new FunctionKeyboard(m_keyBar); 158 m_kb = new FunctionKeyboard(m_keyBar);
159 159
160 /* 160 /*
161 * connect to the menu activation 161 * connect to the menu activation
162 */ 162 */
163 connect( m_sessionsPop, SIGNAL(activated( int ) ), 163 connect( m_sessionsPop, SIGNAL(activated( int ) ),
164 this, SLOT(slotProfile( int ) ) ); 164 this, SLOT(slotProfile( int ) ) );
165 165
166 m_consoleWindow = new TabWidget( this, "blah"); 166 m_consoleWindow = new TabWidget( this, "blah");
167 setCentralWidget( m_consoleWindow ); 167 setCentralWidget( m_consoleWindow );
168 168
169} 169}
170 170
171ProfileManager* MainWindow::manager() { 171ProfileManager* MainWindow::manager() {
172 return m_manager; 172 return m_manager;
173} 173}
174TabWidget* MainWindow::tabWidget() { 174TabWidget* MainWindow::tabWidget() {
175 return m_consoleWindow; 175 return m_consoleWindow;
176} 176}
177void MainWindow::populateProfiles() { 177void MainWindow::populateProfiles() {
178 m_sessionsPop->clear(); 178 m_sessionsPop->clear();
179 Profile::ValueList list = manager()->all(); 179 Profile::ValueList list = manager()->all();
180 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 180 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
181 m_sessionsPop->insertItem( (*it).name() ); 181 m_sessionsPop->insertItem( (*it).name() );
182 } 182 }
183 183
184} 184}
185MainWindow::~MainWindow() { 185MainWindow::~MainWindow() {
186 delete m_factory; 186 delete m_factory;
187 manager()->save(); 187 manager()->save();
188} 188}
189 189
190MetaFactory* MainWindow::factory() { 190MetaFactory* MainWindow::factory() {
191 return m_factory; 191 return m_factory;
192} 192}
193 193
194Session* MainWindow::currentSession() { 194Session* MainWindow::currentSession() {
195 return m_curSession; 195 return m_curSession;
196} 196}
197 197
198QList<Session> MainWindow::sessions() { 198QList<Session> MainWindow::sessions() {
199 return m_sessions; 199 return m_sessions;
200} 200}
201 201
202void MainWindow::slotNew() { 202void MainWindow::slotNew() {
203 qWarning("New Connection"); 203 qWarning("New Connection");
204 ProfileEditorDialog dlg(factory() ); 204 ProfileEditorDialog dlg(factory() );
205 dlg.showMaximized();
205 int ret = dlg.exec(); 206 int ret = dlg.exec();
206 207
207 if ( ret == QDialog::Accepted ) { 208 if ( ret == QDialog::Accepted ) {
208 create( dlg.profile() ); 209 create( dlg.profile() );
209 } 210 }
210} 211}
211 212
212void MainWindow::slotRecordScript() { 213void MainWindow::slotRecordScript() {
213 if (currentSession()) { 214 if (currentSession()) {
214 currentSession()->emulationLayer()->startRecording(); 215 currentSession()->emulationLayer()->startRecording();
215 } 216 }
216} 217}
217 218
218void MainWindow::slotSaveScript() { 219void MainWindow::slotSaveScript() {
219 if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 220 if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
220 MimeTypes types; 221 MimeTypes types;
221 QStringList script; 222 QStringList script;
222 script << "text/plain"; 223 script << "text/plain";
223 types.insert("Script", script); 224 types.insert("Script", script);
224 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 225 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
225 if (!filename.isEmpty()) { 226 if (!filename.isEmpty()) {
226 currentSession()->emulationLayer()->script()->saveTo(filename); 227 currentSession()->emulationLayer()->script()->saveTo(filename);
227 currentSession()->emulationLayer()->clearScript(); 228 currentSession()->emulationLayer()->clearScript();
228 } 229 }
229 } 230 }
230} 231}
231 232
232void MainWindow::slotRunScript() { 233void MainWindow::slotRunScript() {
233 if (currentSession()) { 234 if (currentSession()) {
234 MimeTypes types; 235 MimeTypes types;
235 QStringList script; 236 QStringList script;
236 script << "text/plain"; 237 script << "text/plain";
237 types.insert("Script", script); 238 types.insert("Script", script);
238 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 239 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
239 if (!filename.isEmpty()) { 240 if (!filename.isEmpty()) {
240 Script script(DocLnk(filename).file()); 241 Script script(DocLnk(filename).file());
241 currentSession()->emulationLayer()->runScript(&script); 242 currentSession()->emulationLayer()->runScript(&script);
242 } 243 }
243 } 244 }
244} 245}
245 246
246void MainWindow::slotConnect() { 247void MainWindow::slotConnect() {
247 if ( currentSession() ) 248 if ( currentSession() )
248 currentSession()->layer()->open(); 249 currentSession()->layer()->open();
249} 250}
250 251
251void MainWindow::slotDisconnect() { 252void MainWindow::slotDisconnect() {
252 if ( currentSession() ) 253 if ( currentSession() )
253 currentSession()->layer()->close(); 254 currentSession()->layer()->close();
254} 255}
255 256
256void MainWindow::slotTerminate() { 257void MainWindow::slotTerminate() {
257 if ( currentSession() ) 258 if ( currentSession() )
258 currentSession()->layer()->close(); 259 currentSession()->layer()->close();
259 260
260 slotClose(); 261 slotClose();
261 /* FIXME move to the next session */ 262 /* FIXME move to the next session */
262} 263}
263 264
264void MainWindow::slotConfigure() { 265void MainWindow::slotConfigure() {
265 qWarning("configure"); 266 qWarning("configure");
266 ConfigDialog conf( manager()->all(), factory() ); 267 ConfigDialog conf( manager()->all(), factory() );
267 conf.showMaximized(); 268 conf.showMaximized();
268 269
269 int ret = conf.exec(); 270 int ret = conf.exec();
270 271
271 if ( QDialog::Accepted == ret ) { 272 if ( QDialog::Accepted == ret ) {
272 qWarning("conf %d", conf.list().count() ); 273 qWarning("conf %d", conf.list().count() );
273 manager()->setProfiles( conf.list() ); 274 manager()->setProfiles( conf.list() );
274 populateProfiles(); 275 populateProfiles();
275 } 276 }
276} 277}
277/* 278/*
278 * we will remove 279 * we will remove
279 * this window from the tabwidget 280 * this window from the tabwidget
280 * remove it from the list 281 * remove it from the list
281 * delete it 282 * delete it
282 * and set the currentSession() 283 * and set the currentSession()
283 */ 284 */
284void MainWindow::slotClose() { 285void MainWindow::slotClose() {
285 qWarning("close"); 286 qWarning("close");
286 if (!currentSession() ) 287 if (!currentSession() )
287 return; 288 return;
288 289
289 tabWidget()->remove( currentSession() ); 290 tabWidget()->remove( currentSession() );
290 /*it's autodelete */ 291 /*it's autodelete */
291 m_sessions.remove( m_curSession ); 292 m_sessions.remove( m_curSession );
292 m_curSession = m_sessions.first(); 293 m_curSession = m_sessions.first();
293 tabWidget()->setCurrent( m_curSession ); 294 tabWidget()->setCurrent( m_curSession );
294} 295}
295 296
296/* 297/*
297 * We will get the name 298 * We will get the name
298 * Then the profile 299 * Then the profile
299 * and then we will make a profile 300 * and then we will make a profile
300 */ 301 */
301void MainWindow::slotProfile( int id) { 302void MainWindow::slotProfile( int id) {
302 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 303 Profile prof = manager()->profile( m_sessionsPop->text( id) );
303 create( prof ); 304 create( prof );
304} 305}
305void MainWindow::create( const Profile& prof ) { 306void MainWindow::create( const Profile& prof ) {
306 Session *ses = manager()->fromProfile( prof, tabWidget() ); 307 Session *ses = manager()->fromProfile( prof, tabWidget() );
307 308
308 m_sessions.append( ses ); 309 m_sessions.append( ses );
309 tabWidget()->add( ses ); 310 tabWidget()->add( ses );
310 m_curSession = ses; 311 m_curSession = ses;
311 312
312} 313}
313 314
314void MainWindow::slotTransfer() 315void MainWindow::slotTransfer()
315{ 316{
316 if ( currentSession() ) { 317 if ( currentSession() ) {
317 TransferDialog dlg(this); 318 TransferDialog dlg(this);
318 //dlg.showMaximized(); 319 //dlg.showMaximized();
319 dlg.exec(); 320 dlg.exec();
320 } 321 }
321} 322}
322 323
323 324
324void MainWindow::slotOpenKeb(bool state) { 325void MainWindow::slotOpenKeb(bool state) {
325 326
326 if (state) m_keyBar->show(); 327 if (state) m_keyBar->show();
327 else m_keyBar->hide(); 328 else m_keyBar->hide();
328 329
329} 330}
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 78751e7..c965700 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,127 +1,127 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qwidgetstack.h> 6#include <qwidgetstack.h>
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "widget_layer.h" 10#include "widget_layer.h"
11#include "emulation_widget.h" 11#include "emulation_widget.h"
12#include "metafactory.h" 12#include "metafactory.h"
13#include "profileconfig.h" 13#include "profileconfig.h"
14#include "profilemanager.h" 14#include "profilemanager.h"
15 15
16ProfileManager::ProfileManager( MetaFactory* fact ) 16ProfileManager::ProfileManager( MetaFactory* fact )
17 : m_fact( fact ) 17 : m_fact( fact )
18{ 18{
19 19
20} 20}
21ProfileManager::~ProfileManager() { 21ProfileManager::~ProfileManager() {
22 22
23} 23}
24void ProfileManager::load() { 24void ProfileManager::load() {
25 m_list.clear(); 25 m_list.clear();
26 qWarning("load"); 26 qWarning("load");
27 ProfileConfig conf("opie-console-profiles"); 27 ProfileConfig conf("opie-console-profiles");
28 QStringList groups = conf.groups(); 28 QStringList groups = conf.groups();
29 QStringList::Iterator it; 29 QStringList::Iterator it;
30 30
31 /* 31 /*
32 * for each profile 32 * for each profile
33 */ 33 */
34 for ( it = groups.begin(); it != groups.end(); ++it ) { 34 for ( it = groups.begin(); it != groups.end(); ++it ) {
35 qWarning("group " + (*it) ); 35 qWarning("group " + (*it) );
36 conf.setGroup( (*it) ); 36 conf.setGroup( (*it) );
37 Profile prof; 37 Profile prof;
38 prof.setName( conf.readEntry("name") ); 38 prof.setName( conf.readEntry("name") );
39 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 39 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
40 prof.setTerminalName( conf.readEntry("term").utf8() ); 40 prof.setTerminalName( conf.readEntry("term").utf8() );
41 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); 41 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
42 prof.setBackground( conf.readNumEntry("back") ); 42 prof.setBackground( conf.readNumEntry("back") );
43 prof.setForeground( conf.readNumEntry("fore") ); 43 prof.setForeground( conf.readNumEntry("fore") );
44 prof.setTerminal( conf.readNumEntry("terminal") ); 44 prof.setTerminal( conf.readNumEntry("terminal") );
45 prof.setConf( conf.items( (*it) ) ); 45 prof.setConf( conf.items( (*it) ) );
46 46
47 /* now add it */ 47 /* now add it */
48 m_list.append( prof ); 48 m_list.append( prof );
49 } 49 }
50 50
51} 51}
52void ProfileManager::clear() { 52void ProfileManager::clear() {
53 m_list.clear(); 53 m_list.clear();
54} 54}
55Profile::ValueList ProfileManager::all()const { 55Profile::ValueList ProfileManager::all()const {
56 return m_list; 56 return m_list;
57} 57}
58/* 58/*
59 * Our goal is to create a Session 59 * Our goal is to create a Session
60 * We will load the the IOLayer and EmulationLayer 60 * We will load the the IOLayer and EmulationLayer
61 * from the factory 61 * from the factory
62 * we will generate a QWidgetStack 62 * we will generate a QWidgetStack
63 * add a dummy widget with layout 63 * add a dummy widget with layout
64 * add "Widget" to the layout 64 * add "Widget" to the layout
65 * add the dummy to the stack 65 * add the dummy to the stack
66 * raise the dummy 66 * raise the dummy
67 * call session->connect(= 67 * call session->connect(=
68 * this way we only need to reparent 68 * this way we only need to reparent
69 * in TabWidget 69 * in TabWidget
70 */ 70 */
71Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { 71Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
72 Session* session = new Session(); 72 Session* session = new Session();
73 session->setName( prof.name() ); 73 session->setName( prof.name() );
74 /* translate the internal name to the external */ 74 /* translate the internal name to the external */
75 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , 75 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
76 prof) ); 76 prof) );
77 77
78 QWidgetStack *stack = new QWidgetStack(parent); 78 QWidgetStack *stack = new QWidgetStack(parent);
79 session->setWidgetStack( stack ); 79 session->setWidgetStack( stack );
80 QWidget* dummy = new QWidget(stack ); 80 QWidget* dummy = new QWidget( stack );
81 QHBoxLayout* lay = new QHBoxLayout(dummy ); 81 QHBoxLayout* lay = new QHBoxLayout(dummy );
82 stack->addWidget( dummy, 0 ); 82 stack->addWidget( dummy, 0 );
83 stack->raiseWidget( 0 ); 83 stack->raiseWidget( 0 );
84 WidgetLayer* wid = new EmulationWidget( prof, dummy ); 84 WidgetLayer* wid = new EmulationWidget( prof, dummy );
85 lay->addWidget( wid ); 85 lay->addWidget( wid );
86 86
87 session->setEmulationWidget( wid ); 87 session->setEmulationWidget( wid );
88 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), 88 session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
89 wid ) ); 89 wid ) );
90 session->connect(); 90 session->connect();
91 91
92 return session; 92 return session;
93} 93}
94void ProfileManager::save( ) { 94void ProfileManager::save( ) {
95 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 95 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
96 ProfileConfig conf("opie-console-profiles"); 96 ProfileConfig conf("opie-console-profiles");
97 Profile::ValueList::Iterator it; 97 Profile::ValueList::Iterator it;
98 for (it = m_list.begin(); it != m_list.end(); ++it ) { 98 for (it = m_list.begin(); it != m_list.end(); ++it ) {
99 conf.setGroup( (*it).name() ); 99 conf.setGroup( (*it).name() );
100 conf.writeEntry( "name", (*it).name() ); 100 conf.writeEntry( "name", (*it).name() );
101 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); 101 conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) );
102 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); 102 conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
103 conf.writeEntry( "back", (*it).background() ); 103 conf.writeEntry( "back", (*it).background() );
104 conf.writeEntry( "fore", (*it).foreground() ); 104 conf.writeEntry( "fore", (*it).foreground() );
105 conf.writeEntry( "terminal", (*it).terminal() ); 105 conf.writeEntry( "terminal", (*it).terminal() );
106 /* now the config stuff */ 106 /* now the config stuff */
107 QMap<QString, QString> map = (*it).conf(); 107 QMap<QString, QString> map = (*it).conf();
108 QMap<QString, QString>::Iterator it; 108 QMap<QString, QString>::Iterator it;
109 for ( it = map.begin(); it != map.end(); ++it ) { 109 for ( it = map.begin(); it != map.end(); ++it ) {
110 conf.writeEntry( it.key(), it.data() ); 110 conf.writeEntry( it.key(), it.data() );
111 } 111 }
112 } 112 }
113} 113}
114void ProfileManager::setProfiles( const Profile::ValueList& list ) { 114void ProfileManager::setProfiles( const Profile::ValueList& list ) {
115 m_list = list; 115 m_list = list;
116}; 116};
117Profile ProfileManager::profile( const QString& name )const { 117Profile ProfileManager::profile( const QString& name )const {
118 Profile prof; 118 Profile prof;
119 Profile::ValueList::ConstIterator it; 119 Profile::ValueList::ConstIterator it;
120 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 120 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
121 if ( name == (*it).name() ) { 121 if ( name == (*it).name() ) {
122 prof = (*it); 122 prof = (*it);
123 break; 123 break;
124 } 124 }
125 } 125 }
126 return prof; 126 return prof;
127} 127}