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