-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index b813442..9a226bb 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -40,490 +40,491 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow( | |||
40 | } | 40 | } |
41 | m_factory = new MetaFactory(); | 41 | m_factory = new MetaFactory(); |
42 | Default def(m_factory); | 42 | Default def(m_factory); |
43 | m_sessions.setAutoDelete( TRUE ); | 43 | m_sessions.setAutoDelete( TRUE ); |
44 | m_curSession = 0; | 44 | m_curSession = 0; |
45 | m_manager = new ProfileManager( m_factory ); | 45 | m_manager = new ProfileManager( m_factory ); |
46 | m_manager->load(); | 46 | m_manager->load(); |
47 | 47 | ||
48 | initUI(); | 48 | initUI(); |
49 | populateProfiles(); | 49 | populateProfiles(); |
50 | } | 50 | } |
51 | void MainWindow::initUI() { | 51 | void MainWindow::initUI() { |
52 | setToolBarsMovable( FALSE ); | 52 | setToolBarsMovable( FALSE ); |
53 | 53 | ||
54 | /* tool bar for the menu */ | 54 | /* tool bar for the menu */ |
55 | m_tool = new QToolBar( this ); | 55 | m_tool = new QToolBar( this ); |
56 | m_tool->setHorizontalStretchable( TRUE ); | 56 | m_tool->setHorizontalStretchable( TRUE ); |
57 | 57 | ||
58 | m_bar = new QMenuBar( m_tool ); | 58 | m_bar = new QMenuBar( m_tool ); |
59 | m_console = new QPopupMenu( this ); | 59 | m_console = new QPopupMenu( this ); |
60 | m_scripts = new QPopupMenu( this ); | 60 | m_scripts = new QPopupMenu( this ); |
61 | m_sessionsPop= new QPopupMenu( this ); | 61 | m_sessionsPop= new QPopupMenu( this ); |
62 | //m_settings = new QPopupMenu( this ); | 62 | //m_settings = new QPopupMenu( this ); |
63 | 63 | ||
64 | /* add a toolbar for icons */ | 64 | /* add a toolbar for icons */ |
65 | m_icons = new QToolBar(this); | 65 | m_icons = new QToolBar(this); |
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | /* | 70 | /* |
71 | * the settings action | 71 | * the settings action |
72 | */ | 72 | */ |
73 | m_setProfiles = new QAction(tr("Configure Profiles"), | 73 | m_setProfiles = new QAction(tr("Configure Profiles"), |
74 | Resource::loadPixmap( "SettingsIcon" ), | 74 | Resource::loadPixmap( "SettingsIcon" ), |
75 | QString::null, 0, this, 0); | 75 | QString::null, 0, this, 0); |
76 | // m_setProfiles->addTo( m_settings ); | 76 | // m_setProfiles->addTo( m_settings ); |
77 | m_setProfiles->addTo( m_icons ); | 77 | m_setProfiles->addTo( m_icons ); |
78 | m_setProfiles->addTo( m_console ); | 78 | m_setProfiles->addTo( m_console ); |
79 | connect( m_setProfiles, SIGNAL(activated() ), | 79 | connect( m_setProfiles, SIGNAL(activated() ), |
80 | this, SLOT(slotConfigure() ) ); | 80 | this, SLOT(slotConfigure() ) ); |
81 | 81 | ||
82 | 82 | ||
83 | /* | 83 | /* |
84 | * new Action for new sessions | 84 | * new Action for new sessions |
85 | */ | 85 | */ |
86 | QAction* a = new QAction(tr("New Connection"), | 86 | QAction* a = new QAction(tr("New Connection"), |
87 | Resource::loadPixmap( "new" ), | 87 | Resource::loadPixmap( "new" ), |
88 | QString::null, 0, this, 0); | 88 | QString::null, 0, this, 0); |
89 | a->addTo( m_console ); | 89 | a->addTo( m_console ); |
90 | a->addTo( m_icons ); | 90 | a->addTo( m_icons ); |
91 | connect(a, SIGNAL(activated() ), | 91 | connect(a, SIGNAL(activated() ), |
92 | this, SLOT(slotNew() ) ); | 92 | this, SLOT(slotNew() ) ); |
93 | 93 | ||
94 | /* | 94 | /* |
95 | * connect action | 95 | * connect action |
96 | */ | 96 | */ |
97 | m_connect = new QAction(); | 97 | m_connect = new QAction(); |
98 | m_connect->setText( tr("Connect") ); | 98 | m_connect->setText( tr("Connect") ); |
99 | m_connect->addTo( m_console ); | 99 | m_connect->addTo( m_console ); |
100 | connect(m_connect, SIGNAL(activated() ), | 100 | connect(m_connect, SIGNAL(activated() ), |
101 | this, SLOT(slotConnect() ) ); | 101 | this, SLOT(slotConnect() ) ); |
102 | 102 | ||
103 | /* | 103 | /* |
104 | * disconnect action | 104 | * disconnect action |
105 | */ | 105 | */ |
106 | m_disconnect = new QAction(); | 106 | m_disconnect = new QAction(); |
107 | m_disconnect->setText( tr("Disconnect") ); | 107 | m_disconnect->setText( tr("Disconnect") ); |
108 | m_disconnect->addTo( m_console ); | 108 | m_disconnect->addTo( m_console ); |
109 | connect(m_disconnect, SIGNAL(activated() ), | 109 | connect(m_disconnect, SIGNAL(activated() ), |
110 | this, SLOT(slotDisconnect() ) ); | 110 | this, SLOT(slotDisconnect() ) ); |
111 | 111 | ||
112 | m_transfer = new QAction(); | 112 | m_transfer = new QAction(); |
113 | m_transfer->setText( tr("Transfer file...") ); | 113 | m_transfer->setText( tr("Transfer file...") ); |
114 | m_transfer->addTo( m_console ); | 114 | m_transfer->addTo( m_console ); |
115 | connect(m_transfer, SIGNAL(activated() ), | 115 | connect(m_transfer, SIGNAL(activated() ), |
116 | this, SLOT(slotTransfer() ) ); | 116 | this, SLOT(slotTransfer() ) ); |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * fullscreen | 120 | * fullscreen |
121 | */ | 121 | */ |
122 | m_isFullscreen = false; | 122 | m_isFullscreen = false; |
123 | 123 | ||
124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 124 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
125 | , QString::null, 0, this, 0); | 125 | , QString::null, 0, this, 0); |
126 | m_fullscreen->addTo( m_console ); | 126 | m_fullscreen->addTo( m_console ); |
127 | m_fullscreen->addTo( m_icons ); | 127 | m_fullscreen->addTo( m_icons ); |
128 | connect( m_fullscreen, SIGNAL( activated() ), | 128 | connect( m_fullscreen, SIGNAL( activated() ), |
129 | this, SLOT( slotFullscreen() ) ); | 129 | this, SLOT( slotFullscreen() ) ); |
130 | 130 | ||
131 | /* | 131 | /* |
132 | * terminate action | 132 | * terminate action |
133 | */ | 133 | */ |
134 | m_terminate = new QAction(); | 134 | m_terminate = new QAction(); |
135 | m_terminate->setText( tr("Terminate") ); | 135 | m_terminate->setText( tr("Terminate") ); |
136 | m_terminate->addTo( m_console ); | 136 | m_terminate->addTo( m_console ); |
137 | connect(m_terminate, SIGNAL(activated() ), | 137 | connect(m_terminate, SIGNAL(activated() ), |
138 | this, SLOT(slotTerminate() ) ); | 138 | this, SLOT(slotTerminate() ) ); |
139 | 139 | ||
140 | m_closewindow = new QAction(); | 140 | m_closewindow = new QAction(); |
141 | m_closewindow->setText( tr("Close Window") ); | 141 | m_closewindow->setText( tr("Close Window") ); |
142 | m_closewindow->addTo( m_console ); | 142 | m_closewindow->addTo( m_console ); |
143 | connect( m_closewindow, SIGNAL(activated() ), | 143 | connect( m_closewindow, SIGNAL(activated() ), |
144 | this, SLOT(slotClose() ) ); | 144 | this, SLOT(slotClose() ) ); |
145 | 145 | ||
146 | 146 | ||
147 | /* | 147 | /* |
148 | * script actions | 148 | * script actions |
149 | */ | 149 | */ |
150 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 150 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
151 | m_recordScript->addTo(m_scripts); | 151 | m_recordScript->addTo(m_scripts); |
152 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 152 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
153 | 153 | ||
154 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 154 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
155 | m_saveScript->addTo(m_scripts); | 155 | m_saveScript->addTo(m_scripts); |
156 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 156 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
157 | 157 | ||
158 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 158 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
159 | m_runScript->addTo(m_scripts); | 159 | m_runScript->addTo(m_scripts); |
160 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 160 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
161 | 161 | ||
162 | /* | 162 | /* |
163 | * action that open/closes the keyboard | 163 | * action that open/closes the keyboard |
164 | */ | 164 | */ |
165 | m_openKeys = new QAction (tr("Open Keyboard..."), | 165 | m_openKeys = new QAction (tr("Open Keyboard..."), |
166 | Resource::loadPixmap( "down" ), | 166 | Resource::loadPixmap( "down" ), |
167 | QString::null, 0, this, 0); | 167 | QString::null, 0, this, 0); |
168 | 168 | ||
169 | m_openKeys->setToggleAction(true); | 169 | m_openKeys->setToggleAction(true); |
170 | 170 | ||
171 | connect (m_openKeys, SIGNAL(toggled(bool)), | 171 | connect (m_openKeys, SIGNAL(toggled(bool)), |
172 | this, SLOT(slotOpenKeb(bool))); | 172 | this, SLOT(slotOpenKeb(bool))); |
173 | m_openKeys->addTo(m_icons); | 173 | m_openKeys->addTo(m_icons); |
174 | 174 | ||
175 | 175 | ||
176 | /* | 176 | /* |
177 | * action that open/closes the keyboard | 177 | * action that open/closes the keyboard |
178 | */ | 178 | */ |
179 | m_openButtons = new QAction ( tr( "Open Buttons..." ), | 179 | m_openButtons = new QAction ( tr( "Open Buttons..." ), |
180 | Resource::loadPixmap( "down" ), | 180 | Resource::loadPixmap( "down" ), |
181 | QString::null, 0, this, 0 ); | 181 | QString::null, 0, this, 0 ); |
182 | 182 | ||
183 | m_openButtons->setToggleAction( true ); | 183 | m_openButtons->setToggleAction( true ); |
184 | 184 | ||
185 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), | 185 | connect ( m_openButtons, SIGNAL( toggled( bool ) ), |
186 | this, SLOT( slotOpenButtons( bool ) ) ); | 186 | this, SLOT( slotOpenButtons( bool ) ) ); |
187 | m_openButtons->addTo( m_icons ); | 187 | m_openButtons->addTo( m_icons ); |
188 | 188 | ||
189 | 189 | ||
190 | /* insert the submenu */ | 190 | /* insert the submenu */ |
191 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 191 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
192 | -1, 0); | 192 | -1, 0); |
193 | 193 | ||
194 | /* insert the connection menu */ | 194 | /* insert the connection menu */ |
195 | m_bar->insertItem( tr("Connection"), m_console ); | 195 | m_bar->insertItem( tr("Connection"), m_console ); |
196 | 196 | ||
197 | /* the scripts menu */ | 197 | /* the scripts menu */ |
198 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 198 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
199 | 199 | ||
200 | /* the settings menu */ | 200 | /* the settings menu */ |
201 | // m_bar->insertItem( tr("Settings"), m_settings ); | 201 | // m_bar->insertItem( tr("Settings"), m_settings ); |
202 | 202 | ||
203 | /* and the keyboard */ | 203 | /* and the keyboard */ |
204 | m_keyBar = new QToolBar(this); | 204 | m_keyBar = new QToolBar(this); |
205 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 205 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
206 | m_keyBar->setHorizontalStretchable( TRUE ); | 206 | m_keyBar->setHorizontalStretchable( TRUE ); |
207 | m_keyBar->hide(); | 207 | m_keyBar->hide(); |
208 | 208 | ||
209 | m_kb = new FunctionKeyboard(m_keyBar); | 209 | m_kb = new FunctionKeyboard(m_keyBar); |
210 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), | 210 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), |
211 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); | 211 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); |
212 | 212 | ||
213 | m_buttonBar = new QToolBar( this ); | 213 | m_buttonBar = new QToolBar( this ); |
214 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); | 214 | addToolBar( m_buttonBar, "Buttons", QMainWindow::Top, TRUE ); |
215 | m_buttonBar->setHorizontalStretchable( TRUE ); | 215 | m_buttonBar->setHorizontalStretchable( TRUE ); |
216 | m_buttonBar->hide(); | 216 | m_buttonBar->hide(); |
217 | 217 | ||
218 | m_qb = new QuickButton( m_buttonBar ); | 218 | m_qb = new QuickButton( m_buttonBar ); |
219 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), | 219 | connect( m_qb, SIGNAL( keyPressed( ushort, ushort, bool, bool, bool) ), |
220 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); | 220 | this, SLOT( slotKeyReceived( ushort, ushort, bool, bool, bool) ) ); |
221 | 221 | ||
222 | 222 | ||
223 | m_connect->setEnabled( false ); | 223 | m_connect->setEnabled( false ); |
224 | m_disconnect->setEnabled( false ); | 224 | m_disconnect->setEnabled( false ); |
225 | m_terminate->setEnabled( false ); | 225 | m_terminate->setEnabled( false ); |
226 | m_transfer->setEnabled( false ); | 226 | m_transfer->setEnabled( false ); |
227 | m_recordScript->setEnabled( false ); | 227 | m_recordScript->setEnabled( false ); |
228 | m_saveScript->setEnabled( false ); | 228 | m_saveScript->setEnabled( false ); |
229 | m_runScript->setEnabled( false ); | 229 | m_runScript->setEnabled( false ); |
230 | m_fullscreen->setEnabled( false ); | 230 | m_fullscreen->setEnabled( false ); |
231 | m_closewindow->setEnabled( false ); | 231 | m_closewindow->setEnabled( false ); |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * connect to the menu activation | 234 | * connect to the menu activation |
235 | */ | 235 | */ |
236 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 236 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
237 | this, SLOT(slotProfile( int ) ) ); | 237 | this, SLOT(slotProfile( int ) ) ); |
238 | 238 | ||
239 | m_consoleWindow = new TabWidget( this, "blah"); | 239 | m_consoleWindow = new TabWidget( this, "blah"); |
240 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 240 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
241 | this, SLOT(slotSessionChanged(Session*) ) ); | 241 | this, SLOT(slotSessionChanged(Session*) ) ); |
242 | setCentralWidget( m_consoleWindow ); | 242 | setCentralWidget( m_consoleWindow ); |
243 | 243 | ||
244 | } | 244 | } |
245 | 245 | ||
246 | ProfileManager* MainWindow::manager() { | 246 | ProfileManager* MainWindow::manager() { |
247 | return m_manager; | 247 | return m_manager; |
248 | } | 248 | } |
249 | TabWidget* MainWindow::tabWidget() { | 249 | TabWidget* MainWindow::tabWidget() { |
250 | return m_consoleWindow; | 250 | return m_consoleWindow; |
251 | } | 251 | } |
252 | void MainWindow::populateProfiles() { | 252 | void MainWindow::populateProfiles() { |
253 | m_sessionsPop->clear(); | 253 | m_sessionsPop->clear(); |
254 | Profile::ValueList list = manager()->all(); | 254 | Profile::ValueList list = manager()->all(); |
255 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 255 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
256 | m_sessionsPop->insertItem( (*it).name() ); | 256 | m_sessionsPop->insertItem( (*it).name() ); |
257 | } | 257 | } |
258 | 258 | ||
259 | } | 259 | } |
260 | MainWindow::~MainWindow() { | 260 | MainWindow::~MainWindow() { |
261 | delete m_factory; | 261 | delete m_factory; |
262 | manager()->save(); | 262 | manager()->save(); |
263 | } | 263 | } |
264 | 264 | ||
265 | MetaFactory* MainWindow::factory() { | 265 | MetaFactory* MainWindow::factory() { |
266 | return m_factory; | 266 | return m_factory; |
267 | } | 267 | } |
268 | 268 | ||
269 | Session* MainWindow::currentSession() { | 269 | Session* MainWindow::currentSession() { |
270 | return m_curSession; | 270 | return m_curSession; |
271 | } | 271 | } |
272 | 272 | ||
273 | QList<Session> MainWindow::sessions() { | 273 | QList<Session> MainWindow::sessions() { |
274 | return m_sessions; | 274 | return m_sessions; |
275 | } | 275 | } |
276 | 276 | ||
277 | void MainWindow::slotNew() { | 277 | void MainWindow::slotNew() { |
278 | ProfileEditorDialog dlg(factory() ); | 278 | ProfileEditorDialog dlg(factory() ); |
279 | dlg.showMaximized(); | 279 | dlg.showMaximized(); |
280 | int ret = dlg.exec(); | 280 | int ret = dlg.exec(); |
281 | 281 | ||
282 | if ( ret == QDialog::Accepted ) { | 282 | if ( ret == QDialog::Accepted ) { |
283 | create( dlg.profile() ); | 283 | create( dlg.profile() ); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | void MainWindow::slotRecordScript() { | 287 | void MainWindow::slotRecordScript() { |
288 | /* if (currentSession()) { | 288 | /* if (currentSession()) { |
289 | currentSession()->emulationLayer()->startRecording(); | 289 | currentSession()->emulationLayer()->startRecording(); |
290 | } | 290 | } |
291 | */ | 291 | */ |
292 | } | 292 | } |
293 | 293 | ||
294 | void MainWindow::slotSaveScript() { | 294 | void MainWindow::slotSaveScript() { |
295 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { | 295 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { |
296 | MimeTypes types; | 296 | MimeTypes types; |
297 | QStringList script; | 297 | QStringList script; |
298 | script << "text/plain"; | 298 | script << "text/plain"; |
299 | types.insert("Script", script); | 299 | types.insert("Script", script); |
300 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 300 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
301 | if (!filename.isEmpty()) { | 301 | if (!filename.isEmpty()) { |
302 | currentSession()->emulationLayer()->script()->saveTo(filename); | 302 | currentSession()->emulationLayer()->script()->saveTo(filename); |
303 | currentSession()->emulationLayer()->clearScript(); | 303 | currentSession()->emulationLayer()->clearScript(); |
304 | } | 304 | } |
305 | } | 305 | } |
306 | */ | 306 | */ |
307 | } | 307 | } |
308 | 308 | ||
309 | void MainWindow::slotRunScript() { | 309 | void MainWindow::slotRunScript() { |
310 | /* | 310 | /* |
311 | if (currentSession()) { | 311 | if (currentSession()) { |
312 | MimeTypes types; | 312 | MimeTypes types; |
313 | QStringList script; | 313 | QStringList script; |
314 | script << "text/plain"; | 314 | script << "text/plain"; |
315 | types.insert("Script", script); | 315 | types.insert("Script", script); |
316 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 316 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
317 | if (!filename.isEmpty()) { | 317 | if (!filename.isEmpty()) { |
318 | Script script(DocLnk(filename).file()); | 318 | Script script(DocLnk(filename).file()); |
319 | currentSession()->emulationLayer()->runScript(&script); | 319 | currentSession()->emulationLayer()->runScript(&script); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | */ | 322 | */ |
323 | } | 323 | } |
324 | 324 | ||
325 | void MainWindow::slotConnect() { | 325 | void MainWindow::slotConnect() { |
326 | if ( currentSession() ) { | 326 | if ( currentSession() ) { |
327 | bool ret = currentSession()->layer()->open(); | 327 | bool ret = currentSession()->layer()->open(); |
328 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 328 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
329 | QObject::tr("Failed"), | 329 | QObject::tr("Failed"), |
330 | QObject::tr("Connecting failed for this session.")); | 330 | QObject::tr("Connecting failed for this session.")); |
331 | else { | 331 | else { |
332 | m_connect->setEnabled( false ); | 332 | m_connect->setEnabled( false ); |
333 | m_disconnect->setEnabled( true ); | 333 | m_disconnect->setEnabled( true ); |
334 | } | 334 | } |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::slotDisconnect() { | 338 | void MainWindow::slotDisconnect() { |
339 | if ( currentSession() ) { | 339 | if ( currentSession() ) { |
340 | currentSession()->layer()->close(); | 340 | currentSession()->layer()->close(); |
341 | m_connect->setEnabled( true ); | 341 | m_connect->setEnabled( true ); |
342 | m_disconnect->setEnabled( false ); | 342 | m_disconnect->setEnabled( false ); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void MainWindow::slotTerminate() { | 346 | void MainWindow::slotTerminate() { |
347 | if ( currentSession() ) | 347 | if ( currentSession() ) |
348 | currentSession()->layer()->close(); | 348 | currentSession()->layer()->close(); |
349 | 349 | ||
350 | slotClose(); | 350 | slotClose(); |
351 | /* FIXME move to the next session */ | 351 | /* FIXME move to the next session */ |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow::slotConfigure() { | 354 | void MainWindow::slotConfigure() { |
355 | ConfigDialog conf( manager()->all(), factory() ); | 355 | ConfigDialog conf( manager()->all(), factory() ); |
356 | conf.showMaximized(); | 356 | conf.showMaximized(); |
357 | 357 | ||
358 | int ret = conf.exec(); | 358 | int ret = conf.exec(); |
359 | 359 | ||
360 | if ( QDialog::Accepted == ret ) { | 360 | if ( QDialog::Accepted == ret ) { |
361 | manager()->setProfiles( conf.list() ); | 361 | manager()->setProfiles( conf.list() ); |
362 | manager()->save(); | 362 | manager()->save(); |
363 | populateProfiles(); | 363 | populateProfiles(); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | /* | 366 | /* |
367 | * we will remove | 367 | * we will remove |
368 | * this window from the tabwidget | 368 | * this window from the tabwidget |
369 | * remove it from the list | 369 | * remove it from the list |
370 | * delete it | 370 | * delete it |
371 | * and set the currentSession() | 371 | * and set the currentSession() |
372 | */ | 372 | */ |
373 | void MainWindow::slotClose() { | 373 | void MainWindow::slotClose() { |
374 | if (!currentSession() ) | 374 | if (!currentSession() ) |
375 | return; | 375 | return; |
376 | 376 | ||
377 | Session* ses = currentSession(); | 377 | Session* ses = currentSession(); |
378 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 378 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
379 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 379 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
380 | m_curSession = NULL; | 380 | m_curSession = NULL; |
381 | tabWidget()->remove( /*currentSession()*/ses ); | 381 | tabWidget()->remove( /*currentSession()*/ses ); |
382 | /*it's autodelete */ | 382 | /*it's autodelete */ |
383 | m_sessions.remove( ses ); | 383 | m_sessions.remove( ses ); |
384 | qWarning("after remove!!"); | 384 | qWarning("after remove!!"); |
385 | 385 | ||
386 | if (!currentSession() ) { | 386 | if (!currentSession() ) { |
387 | m_connect->setEnabled( false ); | 387 | m_connect->setEnabled( false ); |
388 | m_disconnect->setEnabled( false ); | 388 | m_disconnect->setEnabled( false ); |
389 | m_terminate->setEnabled( false ); | 389 | m_terminate->setEnabled( false ); |
390 | m_transfer->setEnabled( false ); | 390 | m_transfer->setEnabled( false ); |
391 | m_recordScript->setEnabled( false ); | 391 | m_recordScript->setEnabled( false ); |
392 | m_saveScript->setEnabled( false ); | 392 | m_saveScript->setEnabled( false ); |
393 | m_runScript->setEnabled( false ); | 393 | m_runScript->setEnabled( false ); |
394 | m_fullscreen->setEnabled( false ); | 394 | m_fullscreen->setEnabled( false ); |
395 | m_closewindow->setEnabled( false ); | 395 | m_closewindow->setEnabled( false ); |
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | /* | 399 | /* |
400 | * We will get the name | 400 | * We will get the name |
401 | * Then the profile | 401 | * Then the profile |
402 | * and then we will make a profile | 402 | * and then we will make a profile |
403 | */ | 403 | */ |
404 | void MainWindow::slotProfile( int id) { | 404 | void MainWindow::slotProfile( int id) { |
405 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 405 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
406 | create( prof ); | 406 | create( prof ); |
407 | } | 407 | } |
408 | void MainWindow::create( const Profile& prof ) { | 408 | void MainWindow::create( const Profile& prof ) { |
409 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 409 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
410 | 410 | ||
411 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 411 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
412 | { | 412 | { |
413 | QMessageBox::warning(this, | 413 | QMessageBox::warning(this, |
414 | QObject::tr("Session failed"), | 414 | QObject::tr("Session failed"), |
415 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 415 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
416 | //if(ses) delete ses; | 416 | //if(ses) delete ses; |
417 | return; | 417 | return; |
418 | } | 418 | } |
419 | 419 | ||
420 | m_sessions.append( ses ); | 420 | m_sessions.append( ses ); |
421 | tabWidget()->add( ses ); | 421 | tabWidget()->add( ses ); |
422 | m_curSession = ses; | 422 | m_curSession = ses; |
423 | 423 | ||
424 | // is io_layer wants direct connection, then autoconnect | ||
425 | if ( ( m_curSession->layer() )->supports()[0] = 1 ) { | ||
426 | slotConnect(); | ||
427 | } | ||
428 | |||
429 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 424 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
430 | m_connect->setEnabled( true ); | 425 | m_connect->setEnabled( true ); |
431 | m_disconnect->setEnabled( false ); | 426 | m_disconnect->setEnabled( false ); |
432 | m_terminate->setEnabled( true ); | 427 | m_terminate->setEnabled( true ); |
433 | m_transfer->setEnabled( true ); | 428 | m_transfer->setEnabled( true ); |
434 | m_recordScript->setEnabled( true ); | 429 | m_recordScript->setEnabled( true ); |
435 | m_saveScript->setEnabled( true ); | 430 | m_saveScript->setEnabled( true ); |
436 | m_runScript->setEnabled( true ); | 431 | m_runScript->setEnabled( true ); |
437 | m_fullscreen->setEnabled( true ); | 432 | m_fullscreen->setEnabled( true ); |
438 | m_closewindow->setEnabled( true ); | 433 | m_closewindow->setEnabled( true ); |
434 | |||
435 | |||
436 | // is io_layer wants direct connection, then autoconnect | ||
437 | if ( ( m_curSession->layer() )->supports()[0] = 1 ) { | ||
438 | slotConnect(); | ||
439 | } | ||
439 | } | 440 | } |
440 | 441 | ||
441 | void MainWindow::slotTransfer() | 442 | void MainWindow::slotTransfer() |
442 | { | 443 | { |
443 | if ( currentSession() ) { | 444 | if ( currentSession() ) { |
444 | TransferDialog dlg(this); | 445 | TransferDialog dlg(this); |
445 | dlg.showMaximized(); | 446 | dlg.showMaximized(); |
446 | dlg.exec(); | 447 | dlg.exec(); |
447 | } | 448 | } |
448 | } | 449 | } |
449 | 450 | ||
450 | 451 | ||
451 | void MainWindow::slotOpenKeb(bool state) { | 452 | void MainWindow::slotOpenKeb(bool state) { |
452 | 453 | ||
453 | if (state) m_keyBar->show(); | 454 | if (state) m_keyBar->show(); |
454 | else m_keyBar->hide(); | 455 | else m_keyBar->hide(); |
455 | 456 | ||
456 | } | 457 | } |
457 | 458 | ||
458 | 459 | ||
459 | void MainWindow::slotOpenButtons( bool state ) { | 460 | void MainWindow::slotOpenButtons( bool state ) { |
460 | 461 | ||
461 | if ( state ) { | 462 | if ( state ) { |
462 | m_buttonBar->show(); | 463 | m_buttonBar->show(); |
463 | } else { | 464 | } else { |
464 | m_buttonBar->hide(); | 465 | m_buttonBar->hide(); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | 468 | ||
468 | 469 | ||
469 | 470 | ||
470 | void MainWindow::slotSessionChanged( Session* ses ) { | 471 | void MainWindow::slotSessionChanged( Session* ses ) { |
471 | qWarning("changed!"); | 472 | qWarning("changed!"); |
472 | if ( ses ) { | 473 | if ( ses ) { |
473 | m_curSession = ses; | 474 | m_curSession = ses; |
474 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 475 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
475 | if ( m_curSession->layer()->isConnected() ) { | 476 | if ( m_curSession->layer()->isConnected() ) { |
476 | m_connect->setEnabled( false ); | 477 | m_connect->setEnabled( false ); |
477 | m_disconnect->setEnabled( true ); | 478 | m_disconnect->setEnabled( true ); |
478 | } else { | 479 | } else { |
479 | m_connect->setEnabled( true ); | 480 | m_connect->setEnabled( true ); |
480 | m_disconnect->setEnabled( false ); | 481 | m_disconnect->setEnabled( false ); |
481 | } | 482 | } |
482 | } | 483 | } |
483 | } | 484 | } |
484 | 485 | ||
485 | void MainWindow::slotFullscreen() { | 486 | void MainWindow::slotFullscreen() { |
486 | 487 | ||
487 | if ( m_isFullscreen ) { | 488 | if ( m_isFullscreen ) { |
488 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 489 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
489 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 490 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
490 | setCentralWidget( m_consoleWindow ); | 491 | setCentralWidget( m_consoleWindow ); |
491 | ( m_curSession->widgetStack() )->show(); | 492 | ( m_curSession->widgetStack() )->show(); |
492 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 493 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
493 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 494 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
494 | 495 | ||
495 | } else { | 496 | } else { |
496 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 497 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
497 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 498 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
498 | , QPoint(0,0), false ); | 499 | , QPoint(0,0), false ); |
499 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 500 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
500 | ( m_curSession->widgetStack() )->setFocus(); | 501 | ( m_curSession->widgetStack() )->setFocus(); |
501 | ( m_curSession->widgetStack() )->show(); | 502 | ( m_curSession->widgetStack() )->show(); |
502 | 503 | ||
503 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 504 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
504 | 505 | ||
505 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 506 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
506 | } | 507 | } |
507 | 508 | ||
508 | m_isFullscreen = !m_isFullscreen; | 509 | m_isFullscreen = !m_isFullscreen; |
509 | } | 510 | } |
510 | 511 | ||
511 | 512 | ||
512 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { | 513 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool pressed, bool) { |
513 | 514 | ||
514 | qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); | 515 | qWarning("unicode: %x, qkey: %x, %s", u, q, pressed ? "pressed" : "released"); |
515 | 516 | ||
516 | if ( m_curSession ) { | 517 | if ( m_curSession ) { |
517 | 518 | ||
518 | QEvent::Type state; | 519 | QEvent::Type state; |
519 | 520 | ||
520 | if (pressed) state = QEvent::KeyPress; | 521 | if (pressed) state = QEvent::KeyPress; |
521 | else state = QEvent::KeyRelease; | 522 | else state = QEvent::KeyRelease; |
522 | 523 | ||
523 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); | 524 | QKeyEvent ke(state, q, u, 0, QString(QChar(u))); |
524 | 525 | ||
525 | // where should i send this event? doesnt work sending it here | 526 | // where should i send this event? doesnt work sending it here |
526 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); | 527 | QApplication::sendEvent((QObject *)m_curSession->widget(), &ke); |
527 | ke.ignore(); | 528 | ke.ignore(); |
528 | } | 529 | } |
529 | } | 530 | } |